python - Click on a link having a href attribute within <li> -
i trying click on login link system throws nosuchelementexception. have tried xpaths unable click on login button , attaching code
from selenium import webdriver selenium.webdriver.common.by import import time class createaccount: def signup(self): browser = webdriver.firefox() browser.get("http://www.scrumdo.com") time.sleep(5) browser.find_element_by_link_text("login").click() time.sleep(5) browser.find_element_by_xpath("//a[@href='/account/signup']").click() time.sleep(5) browser.find_element_by_xpath("//input[@name='username']").send_keys("rockyhandsome") browser.find_element_by_xpath("//input[@name='fullname']").send_keys("naqash zafar") browser.find_element_by_xpath("//input[@name='email']").send_keys("naqash.zafar@kualitatem.com") browser.find_element_by_xpath("//input[@name='password']").send_keys("k12345678") browser.find_element_by_xpath("//button[@type='submit']").click() ca = createaccount() ca.signup()
trace details
traceback (most recent call last): file "c:/users/naqash.zafar/pycharmprojects/assignments/createaccountonscrumdo.py", line 38, in <module> ca.signup() file "c:/users/naqash.zafar/pycharmprojects/assignments/createaccountonscrumdo.py", line 15, in signup browser.find_element_by_link_text("login").click() file "c:\users\naqash.zafar\appdata\local\programs\python\python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 314, in find_element_by_link_text return self.find_element(by=by.link_text, value=link_text) file "c:\users\naqash.zafar\appdata\local\programs\python\python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 744, in find_element {'using': by, 'value': value})['value'] file "c:\users\naqash.zafar\appdata\local\programs\python\python35-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 233, in execute self.error_handler.check_response(response) file "c:\users\naqash.zafar\appdata\local\programs\python\python35-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 194, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.nosuchelementexception: message: unable locate element: {"method":"link text","selector":"login"} stacktrace: @ firefoxdriver.prototype.findelementinternal_ (file:///c:/users/naqash~1.zaf/appdata/local/temp/tmpiln2m889/extensions/fxdriver@googlecode.com/components/driver-component.js:10770) @ firefoxdriver.prototype.findelement (file:///c:/users/naqash~1.zaf/appdata/local/temp/tmpiln2m889/extensions/fxdriver@googlecode.com/components/driver-component.js:10779) @ delayedcommand.prototype.executeinternal_/h (file:///c:/users/naqash~1.zaf/appdata/local/temp/tmpiln2m889/extensions/fxdriver@googlecode.com/components/command-processor.js:12661) @ delayedcommand.prototype.executeinternal_ (file:///c:/users/naqash~1.zaf/appdata/local/temp/tmpiln2m889/extensions/fxdriver@googlecode.com/components/command-processor.js:12666) @ delayedcommand.prototype.execute/< (file:///c:/users/naqash~1.zaf/appdata/local/temp/tmpiln2m889/extensions/fxdriver@googlecode.com/components/command-processor.js:12608) process finished exit code 1
you need click menu dropdown select login button:
class createaccount: def signup(self): browser = webdriver.firefox() browser.get("http://www.scrumdo.com") menu = browser.find_element_by_xpath("//button[@class='navbar-toggle']") menu.click() time.sleep(.25) menu.find_element_by_xpath("//li/a[@mixpanel='homepage clicked login']").click() browser.find_element_by_xpath("//a[@href='/account/signup']").click() time.sleep(.25) browser.find_element_by_xpath("//input[@name='username']").send_keys("rockyhandsome") browser.find_element_by_xpath("//input[@name='fullname']").send_keys("naqash zafar") browser.find_element_by_xpath("//input[@name='email']").send_keys("naqash.zafar@kualitatem.com") browser.find_element_by_xpath("//input[@name='password']").send_keys("k12345678") browser.find_element_by_xpath("//button[@type='submit']").click()
Comments
Post a Comment