I am trying to automate clicking on a button of a webpage where the source code has the following structure:
<div id="ctl02_" class="sel">
<div id="Lo" class="cont">
<div class="cl">
<span onclick="__doPostBack('ct$ctl00','M_CC_1')"
class="fakeLink" title="add "D"">
<img src="Skin/D.png" alt="add "D"" class="io"
/> D</span> <br />
I am currently trying to accomplish this with the use of python and Selenium. Below you can find how I am trying to do this:
driver = webdriver.Firefox()
driver.wait = WebDriverWait(driver, 5)
driver.get("http://www.thewebpageIwanttoclickforwardto.com")
try:
elem = driver.wait.until(EC.presence_of_element_located((By.XPATH, "//div[@class='cl']")))
except TimeoutException:
print("Element not found")
elem.click()
The program finishes fine (exit code 0), however, the webdriver has not moved to the webpage behind the click (which I would encounter if I would physically click on the button D on the webpage). I have tried many things giving me the feeling that I am missing something basic here.
Where am I going wrong here? Am I using Selenium in a wrong way here? Or is Selenium not the right tool for this?