Hi i need to check for an element using python Selenium. If the element is found then i in need to click on it or else click on the next page and search the element again.This continues until the element is found.
The code i have used is :
1. element_path="//span[contains(text(),'ABC Company')]"
2. while True:
3. if(driver.find_elements_by_xpath(element_xpath)):
driver.find_element_by_xpath(element_xpath).click()
4. else: driver.find_element_by_xpath("xpath to goto next page").click()
But this code doesn't work as I'm getting an error: no such element: {"method":"xpath","selector":"//span[contains(text(),'ABC Company')]"}
Can this looping be done in any other method? Thanks in Advance