I face the following issue: there is a page (unfortunately it's not public) with a Register request
and a Approve request
button. Clicking on a button leads to opening a transparent div
with a pop-up.
Algorithm is as following:
1) Click Register
;
2) Fill form in raised pop-up;
3) Click Submit
to confirm registration (to close pop-up);
4) Click Approve
So I use the following code:
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//button[@id="RegisterButton"]'))).click()
# ...Filling Register form...
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//button[@id="SubmitButton"]'))).click()
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//button[@id="ApproveButton"]'))).click()
But despite using EC.element_to_be_clickable()
I get the following error:
WebDriverException: Message: unknown error:
Element is not clickable at point (338, 167).
Other element would receive the click: <div class="modal fade" id="confirmWindow" style="display: block;">...</div>
Seems that the driver considers Approve
being already clickable and tries to click on it while the transparent div
is still displayed.
So I need an Expected Conditions
statement to catch the state when the div
is already selected and Approve
if the button is clickable
P.S. I'm using time.sleep()
to do this, but seems to be a rough approach
UPDATED
I try to use JavaScript
:
driver.execute_script('document.getElementById("ApproveButton").click();')
and so far it works... I wonder if it really a better way to click on button or there could be some obstacles also?