0

I am trying to click a button, which is in the popup, but it is giving me the following error:

Message: Element <button id="modal_ok" class="btn btn-primary waves-effect waves-light" type="button"> could not be scrolled into view

My HTML content for this is:

<button type="button" id="modal_ok" onclick="$('#disable_1').hide(); $('#form_disable_1').submit();" class="btn btn-primary waves-effect waves-light">Ok</button>

The code I have written is as follows:

ok_button = browser.find_element_by_id("modal_ok")
self.assertIsNotNone(ok_button)
# ok_button.click()
WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.ID, "modal_ok"))).click()

The assert is working, which means the element is visible, but I am not able to click it because of the aforementioned error.

0

1 Answer 1

1

Coder,

You can try with Javascript executor :

Code :

ok_button = browser.find_element_by_id("modal_ok")
self.assertIsNotNone(ok_button)
driver.execute_script("arguments[0].click();", ok_button)   

Or you can try with this code :

ok_button = browser.find_element_by_id("modal_ok")
self.assertIsNotNone(ok_button)
driver.execute_script("arguments[0].scrollIntoView(true);", ok_button)   
ok_button.click()
Sign up to request clarification or add additional context in comments.

1 Comment

Have tried all these but its not working :(

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.