The xpath for the element I am searching for is correct.
All elements before it have been located and have had action taken upon them via xpath.
However for this one instance location by xpath is failing. Almost if the website was actively denying its existence when I search for it in Selenium.
Has anyone had experience with this? Can I be pointed in a direction to learn more about it, and how to fix it.
website I am automating is facebook.com
My mouse is over the form I'm trying to find and input to in the picture below
The relevant code is below:
# from facebook homepage search search for the group waitForElements(['homepageSearchBarsearchButton']) #STACK OVERFLOW CODE FAILS HERE element = driver.find_element_by_xpath((xpath['homepageSearchField'])) element.send_keys(passedText['homepageSearchBarInput']) time.sleep(randomWait()) element = driver.find_element_by_xpath(xpath['homepageSearchBarsearchButton']) element.click() wait For Elements function below
def waitForElements(xpaths = [], *args): elementLoad = None for x in xpaths: # noinspection PyRedeclaration elementLoad = WebDriverWait(driver,20).until(EC.presence_of_element_located((By.XPATH, xpath[x]))) The failure trace below:
File "/home/honeytoes/PycharmProjects/Chicags20sEarly30s/lookingForTagCompliance/lookingForTagCompliance/workingFile.py", line 108, in <module> element = driver.find_element_by_xpath(xpath['groupSearchField']) File "/home/honeytoes/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 258, in find_element_by_xpath return self.find_element(by=By.XPATH, value=xpath) File "/home/honeytoes/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 712, in find_element {'using': by, 'value': value})['value'] File "/home/honeytoes/.local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 201, in execute self.error_handler.check_response(response) File "/home/honeytoes/.local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 181, in check_response raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"xpath","selector":".//*[@id='u_jsonp_5_2']/span/span/input"} Stacktrace: Thank you
No comments:
Post a Comment