skip to Main Content

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" />&nbsp;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" />&nbsp;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


  1. Chosen as BEST ANSWER

    Activation of the most recent window: driver.switch_to_window(driver.window_handles[-1])


  2. Have you tried locating the element by Class Name?

    content = driver.find_element_by_class_name('icon ic_s_status')
    content = driver.find_element_by_class_name('icon ic_b_export')
    
    Login or Signup to reply.
  3. To click() on the element with text as Exporteren you have to induce WebDriverWait for the element_to_be_clickable() and you can use either of the following Locator Strategies:

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search