Headless Browser using HTML UNIT Driver
You
will learn how to execute your scripts in Headless browser using HTML UNIT driver.
Scenario :
Enter UserName and
Password
Click on the Login
button.
Verify the Window Title
Close the browser
Precondition : You need
to run the Selenium Standalone server for executing Headless browser using
HTMLUNIT
Selenium Standalone
server should up and running because HTMLUnit is implemented on the Java side for
that you should navigate to where your Selenium standalone server is located and type below command in command line
Ex:
c:\software\seleniums> java -jar selenium-server-standalone-3.14.0.jar
Script:
from
selenium import webdriver
from
selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driver=webdriver.Remote(desired_capabilities=webdriver.DesiredCapabilities.HTMLUNIT)
driver.get("http://newtours.demoaut.com")
driver.find_element_by_name("userName").send_keys("hello")
driver.find_element_by_name("password").send_keys("hello")
driver.find_element_by_name("login").click()
print(driver.title)
driver.close()
Comments
Post a Comment