Ashutosh Singh Ashutosh Singh - 13 days ago 4
Python Question

Keys.ESCAPE in selenium webdriver(python)

I am using selenium

webdriver
(with
python
). I have a use case where I want to test that submit button get disabled once the form get submited. To test it, I send
ESCAPE
key to stop the page to load next page so that I can access the elements of same page.

password.send_keys("abcdef", Keys.ENTER, Keys.ESCAPE)


The problem is that it works fine in Firefox browser but it is not working in Chrome. In Chrome sending
ESCAPE
seems to be not working and it submits the form and loads the next page.

Is there any other solution or workaround to overcome this?

Answer

After trying many options, finally the following option seems to be working -

password.send_keys("abcdef", Keys.ENTER, Keys.ESCAPE)  # this works for Firefox driver
drive.execute_script("window.stop();")                 # this works for Chrome driver
Comments