Ashutosh Singh Ashutosh Singh - 8 months ago 51
Python Question

Keys.ESCAPE in selenium webdriver(python)

I am using selenium

). 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
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
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?


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