Python Selenium - NamespaceError incorrect namespaces
Ahoj,
používám Python + Selenium a jako indentifikaci HTML elementů Xpath. Moje definice jednoho elemenetu je:
Firefox s doplňkem Xpath checker tuto definici v pohodě uznává, avšak když pak spustím skript, tak dostanu tuto chybu
Ahoj,
zkus z xpath odstranit
používám Python + Selenium a jako indentifikaci HTML elementů Xpath. Moje definice jednoho elemenetu je:
positiveORVXPosition = "id('major_select__View_3')/x:div/x:div/x:div/x:div/x:table/x:tbody/x:tr/x:td"
Firefox s doplňkem Xpath checker tuto definici v pohodě uznává, avšak když pak spustím skript, tak dostanu tuto chybu
NamespaceError: An attempt was made to create or change an object in a way which is incorrect with regard to namespaces
, avšak já v Xpath žádný mezery nevidím, co s tím? děkuji předem
Traceback (most recent call last):
File "/var/selenium/selenium-test2.py", line 194, in
xcboLoop()
File "/var/selenium/selenium-test2.py", line 121, in xcboLoop
xcboLoop()
File "/var/selenium/selenium-test2.py", line 150, in xcboLoop
checkPositiveORVXPositionElement = len(driver.find_elements_by_xpath(positiveORVXPosition))
File "/usr/lib/python3.4/site-packages/selenium/webdriver/remote/webdriver.py", line 325, in find_elements_by_xpath
return self.find_elements(by=By.XPATH, value=xpath)
File "/usr/lib/python3.4/site-packages/selenium/webdriver/remote/webdriver.py", line 817, in find_elements
'value': value})['value']
File "/usr/lib/python3.4/site-packages/selenium/webdriver/remote/webdriver.py", line 256, in execute
self.error_handler.check_response(response)
File "/usr/lib/python3.4/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.InvalidSelectorException: Message: Given xpath expression "id('major_select__View_3')/x:div/x:div/x:div/x:div/x:table/x:tbody/x:tr/x:td" is invalid: NamespaceError: An attempt was made to create or change an object in a way which is incorrect with regard to namespaces
ODPOVĚĎ
Ahoj,
zkus z xpath odstranit
x:
takto:positiveORVXPosition = "id('major_select__View_3')/div/div/div/div/table/tbody/tr/td"