Collections:
Submit Web Form with WebDriver in Python
How to submit Web Page Form with Selenium WebDriver in Python?
✍: FYIcenter.com
You can follow this tutorial to enter input data and submit a Web page form with Selenium WebDriver.
Several methods from Selenium WebDriver classes will be used:
1. Enter the following program, FormSubmit.py:
# FormSubmit.py
# Copyright (c) FYIcenter.com
from selenium.webdriver import Chrome
import time
driver = Chrome()
driver.get("http://sqa.fyicenter.com")
# get the first "form" element in the page
form = driver.find_element_by_tag_name("form")
# get the input element of the form.
query = form.find_element_by_name("Q")
query.send_keys("selenium")
# submit form
form.submit()
url = driver.current_url
print("Test Case - Submit a search:")
print(" Actual Value: "+url)
print(" Expected Value: ..Q=selenium...")
if (url.endswith("Q=selenium")):
print(" Test Result: Passed")
else:
print(" Test Result: Failed")
# pause for 1 minute before closing
time.sleep(60)
driver.quit()
2. Compile and run it with the Selenium Client JAR file.
C:\fyicenter>python FormSubmit.py DevTools listening on ws://127.0.0.1:60370/devtools/browser/... Test Case - Submit a search: Actual Value: http://sqa.fyicenter.com/index.php?Q=selenium Expected Value: ..Q=selenium... Test Result: Passed
As you can see, we are able to enter a search criteria and submit the FORM element without any problem with Chrome WebDriver.
⇒ execute_script() to Run JavaScript in Java
⇐ Retrieve Web Form Elements with WebDriver in Python
2019-10-18, ∼1974🔥, 0💬
Popular Posts:
Why I am getting gzip compressed HTTP response in SoapUI? If you run a HTTP request for some Website...
How to valid IPv6 addresses? In order to help your programming or testing tasks, FYIcenter.com has d...
How to convert hexadecimal encoded data back to binary data (or Hex to Binary Decoding)? Hex to Bina...
How to expand IPv6 addresses? In order to help your programming or testing tasks, FYIcenter.com has ...
Where to find tutorials on Test Management? I want to know how to manage software testing documents ...