Access to a hosted MariaDB using a connector is not allowed by the provider. I therefore try to export some tables using a Python script with Selenium. I do not manage to find / click the export button of phpMyAdmin.
I try to locate the button using its XPATH, obtained with the Chrome browser.
I updated Chrome, the driver, Selenium to the latest versions. Attempted to make the driver wait:
(WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='navigationbar']/ul[@id='topmenu']//li//img[@title='Exporteren']"))).click())
The problem is that for some reason, the button cannot be found by the driver.
I tried to search by xpath, class, css, … without success.
I do not find any frame in the html code.
Below some html code (that seems to get interpreted in the question…)
HTML:
<div class="navigationbar"><ul id="topmenu" class="resizable-menu">
<li>
<a href="server_status.php" class="tab">
<img src="themes/dot.gif" title="Status" alt="Status" class="icon ic_s_status" /> Status
</a>
</li>
<li>
<a href="server_export.php" class="tab">
<img src="themes/dot.gif" title="Exporteren" alt="Exporteren" class="icon ic_b_export" /> Exporteren
</a>
</li>
<li>
Code trials:
python
btnexp = driver.find_element_by_xpath("//*[@id='topmenu']/li[4]/a/img")
btnexp.click()
Error message:
no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id='topmenu']/li[4]/a/img"}
3
Answers
Activation of the most recent window: driver.switch_to_window(driver.window_handles[-1])
Have you tried locating the element by Class Name?
To
click()
on the element with text as Exporteren you have to induce WebDriverWait for theelement_to_be_clickable()
and you can use either of the following Locator Strategies:Using
CSS_SELECTOR
:Using
XPATH
:Note : You have to add the following imports :
You can find a couple of relevant discussions in: