I am trying to automate an access point web configuration. During this, I get a pop up (kind of an overlay with "Yes" and "No") which i want to click on
The HTML code for the overlay that I am trying to click on:
<div id="generic-warning-dialog" class="dialog exclamation text-orphan" style="">
<div class="warning-content dialog-content text-orphan">Security Mode is disabled on one or more of your wireless networks. Your network could be open to unauthorized users. Are you sure you wish to proceed?</div>
<div class="dialog-buttons text-orphan">
<button class="cancel">No</button>
<button class="submit" style="display: block;">Yes</button>
</div>
</div>
I tried
browser.find_element_by_class_name("submit").click()
but I get the following error:
raise exception_class(message, screen, stacktrace) selenium.common.exceptions.ElementClickInterceptedException: Message: Element is not clickable at point (788,636.5) because another element obscures it
Can you please advise on how should i proceed? I am using firefox and python
You can Replace click event with action class
Using Action Class :
from selenium.webdriver.common.action_chains import ActionChains
actions = ActionChains(driver)
actions.move_to_element("Your Web Element").click().perform()
As per your question and the HTML you have shared, you need to induce WebDriverWait for the desired element to be clickable and you can use the following solution:
#to click on Yes button
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='warning-content dialog-content text-orphan' and contains(.,'Security Mode is disabled')]//following::div[1]//button[@class='submit']"))).click()
# to click on No button
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='warning-content dialog-content text-orphan' and contains(.,'Security Mode is disabled')]//following::div[1]//button[@class='cancel']"))).click()
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With