the function:
def twoclicks(idoutter,idinner):
wait = WebDriverWait(driver, 20)
wait.until(EC.element_to_be_clickable((By.XPATH, "//input[contains(@id," + idoutter + ") and @value='...']"))).click()
sleep(5)
wait.until(EC.element_to_be_clickable((By.ID, idinner))).click()
This function is used to click an element then have a pop up a few seconds later and click an element of the popup.
I keep getting that error although i tried adding sleep()
in my function and it's inconsistent as in i get it at times and i don't at others.
My previous function was:
def twoclicks(idoutter,idinner):
outter = driver.find_element_by_xpath("//input[contains(@id," + idoutter + ") and @value='...']")
outter.click()
sleep(10)
driver.find_element_by_id(idinner).click()
sleep(7)
although my second function is a bad practice and the first one is supposed to be an improvement but i didn't get that exception using my second one.How can i adjust my first shared function to get rid of that error.
kindly note the code is a continuous call for similar functions like :
twoclicks("'button1'", 'button2')
twoclicks("'button3'", 'button4')
The div obscurint it is :
<div class="rich-mpnl-mask-div-opaque rich-mpnl-mask-div" id="PWBFormID:managerModalPanelDiv" style="z-index: -1;"><button class="rich-mpnl-button" id="PWBFormID:managerModalPanelFirstHref"></button></div>
it's in grey in the html(when inspecting).
I saw many methods like using execute_script()
to block the div with the shared class above but the issue is i'm using a function for it and have dozens of buttons that won't have that issue or potentially have it with a different class which is making getting rid of such cases without manually writing a code for them alone case by case outside my twoclicks()
function very difficult.