Create TestScript for other Browsers


How to run your scripts in chrome Browser.
you will learn how to execute your selenium script with python for Google Chrome browser

Scenario :
Invoke Google Chrome browser.
Enter UserName and Password
Click on the Login button.
Verify the Window Title
Close the browser

Precondition : you should download the chrome driver by selecting the appropriate version of your browser

Script
from selenium import webdriver 
chromePath="C:\\resources\\executables\\chromedriver.exe"
driver=webdriver.Chrome(executable_path=chromePath)
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()


    How to run your scripts in Internet Explorer Browser.
you will learn how to execute your selenium script with python for Internet Explorer browser

Scenario :
Invoke IE browser.
Enter UserName and Password
Click on the Login button.
Verify the Window Title
Close the browser

Precondition : you should download the IEDriverServer by selecting the appropriate version of your browser

 Script
from selenium import webdriver 
chromePath="C:\\resources\\executables\\chromedriver.exe"
driver=webdriver.Chrome(executable_path=chromePath) 
driver=webdriver.Chrome(executable_path=chromePath)
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()


           How to run your scripts in Brave Browser.
          you will learn how to execute your selenium script with python for Brave Browser.

           Scenario :
           Invoke Brave browser.
           Open URL: http://newtours.demoaut.com
           Enter User Name and Password
           Click on the Login button.
           Verify the Window Title
           Close the browser

          Precondition : you should download the chrome driver because Brave Browser is based on the Chromium web browser,so no separate browser driver for Brave Browser.

        from selenium import webdriver
        from selenium.webdriver.chrome.options import Options

       chromePath=
"C:\\BrowserDrivers\\chromedriver.exe"
        chrome_opt=Options()
        chrome_opt.binary_location="C:\\Program Files (x86)\\BraveSoftware\\Brave-                Browser\\Application\\brave.exe"
 driver=webdriver.Chrome(chromePath,options=chrome_opt)
        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