Ashutosh Singh Ashutosh Singh - 1 year ago 115
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?

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download