In Automation Testing using Selenium WebDriver, the basic approach is to identify elements using locators and perform various operations on them by defining programming logic.
For instance, below is the Login code using Selenium with Python:
#import “webdriver” from selenium
from selenium import webdriver
#load chrome driver using path of its windows directory
driver = webdriver.Chrome(executable_path='Path of exe driver\chromedriver.exe')
#maximize the browser
driver.maximize_window()
#navigate to url
driver.get(“https://www.example.com/”)
#xpath of “email” text box to enter email
driver.find_element_by_xpath(“//*[@id='email']”).send_keys(“******@yopmail.com”)
#xpath of “password” text box to enter password
driver.find_element_by_xpath(“//*[@id='pass']”).send_keys(“Test1234567”)
#xpath of “login” button to click on login button
driver.find_element_by_xpath(“//*[@name='login']”).click()
from selenium import webdriver
#load chrome driver using path of its windows directory
driver = webdriver.Chrome(executable_path='Path of exe driver\chromedriver.exe')
#maximize the browser
driver.maximize_window()
#navigate to url
driver.get(“https://www.example.com/”)
#xpath of “email” text box to enter email
driver.find_element_by_xpath(“//*[@id='email']”).send_keys(“******@yopmail.com”)
#xpath of “password” text box to enter password
driver.find_element_by_xpath(“//*[@id='pass']”).send_keys(“Test1234567”)
#xpath of “login” button to click on login button
driver.find_element_by_xpath(“//*[@name='login']”).click()
Post a Comment