-2

'Untill login its fine all button works fine but then afte the login I am trying to click tis export button its not clicking/ as per my test its not finding it. Not juts the export button any other button it cannot find it in the page after the login. then I get the time out error. ' error Imagedev tool with the button try:

    iframe = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.TAG_NAME, 'iframe')))
    driver.switch_to.frame(iframe)
    print("Switched to iframe")
    
   
    export_button = WebDriverWait(driver, 20).until(
        EC.element_to_be_clickable((By.XPATH, '//*[@id="filterReportResults"]'))
    )
    
    ActionChains(driver).move_to_element(export_button).perform()
    print("Moved to export button")
    
    
    driver.execute_script("arguments[0].click();", export_button)
    print("Export button clicked via JavaScript")
    
    csv_element = WebDriverWait(driver, 20).until(
        EC.element_to_be_clickable((By.XPATH, '//*[@id="linkCSV"]/span[1]'))
    )
    csv_element.click()
    print("CSV link clicked successfully.")
    
except Exception as e:
    print(f"Error occurred: {e}")
finally:
    driver.quit()
1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. Commented Oct 10, 2024 at 7:24

1 Answer 1

1

I also had this problem in the past. In my case, an hidden element was "over" the button. You can see it in the developer options. Also a possible reason could be, that you are too fast, so that the button is not enabled yet (I also had this problem in the past)

If the button is not clickable through standard methods, try JavaScript, it can sometimes help.

driver.execute_script("arguments.click();", export_button)
Sign up to request clarification or add additional context in comments.

8 Comments

Hi Alex, its actually not working for anything. I tried it. For some reason it cannot locate the export button.
So I tried clicking another button not in the same menu bar it clicks but when I click that button it does not. Can I show you my dev tool screenshot or something that might help you help me?
Yes, show me the layout you have
hey Alex look at the post again I have added the image with the button as well, named dev tool.
Is the element next to it (PDF) clickable? Otherwise you can see what the difference there is in the code. With Ctrl+Shift+C you can check whether the padding or something else on a neighboring element is not quite right, so that Selenium cannot find the element. Or you can simply add a longer waiting time
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.