vim, git, aws and other three-letter words

Software Development Notes

Selenium WebDriver: get WebElement by jQuery selector

This can be necessary for example for selector like #id > li:visible.

If you try to do webdriver.find_element_by_css_selector you will get an error message "The given selector #id > li:visible is either invalid or does not result in a WebElement."

The workaround is to use jQuery to find the element. It can be done with this code (python):

script = "return $('"+selector+"').get(0);"
element = webdriver.execute_script(script);

Tags: web