Java Script Executor and Waits

Hello Everyone,

Good Day to all of you and I have stumbled upon an issue I can’t find a clear answer to,

Please look at the below code in Python Selenium for a click,

WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.XPATH, "html/div/div[2]/div/div[4]/div/div/div[1]/div/div/div/div"))).click()

  • Now this code has a 20 second wait time for the element to be present before it throws in an error killing the script,

Similarly in Javascriptexecutor of python selenium I have the below code which does the same as above,

confirm = browser.find_element(By.XPATH, 'html/div/div[2]/div/div[4]/div/div/div[1]/div/div/div/div')
browser.execute_script("arguments[0].click();", confirm)

The issue I have here is the Javascript executor here doesn’t have a wait time before throwing an exception,

How can I tackle Javascript executor with a wait time similar to the python selenium code?

Thank you :slight_smile:

I haven’t really used selenium that much but the docs have some examples.

Thank you very much for your response.

I will have a look at it and test it with some examples I found there reading through it.
If any of the solutions there helped me out I will update in here.

Thank you very much :slight_smile:

Dear Brother,

Thanks a lot man,
it was a success.

The issue has been about my understanding in how the languages works as a self studying individual.

I assigned the element via python and managed the execution of it via JSE which solved the issue.

Thank you and have a great day buddy.

Do Tc.