0 likes | 16 Vues
When initiating the testing phase for any website or web application, the primary test case involves evaluating the functionality of the login feature. Now, the challenge is to automate the login feature of a website. This presentation addresses how to automate the login process, focusing on an E-learning website.<br><br>Agenda:<br><br>1. Introduction<br>2. Scenarios to consider<br>3. Various methods employed for automating the login process<br>4. The final segment covers the actual code.<br><br>For inquiries or concerns, feel free to email us at training@infotek-solutions.com or call us at (800) 543-5571.
E N D
How to automate the login process to an e-learning website using Selenium Webdriver ? Lets understand the scenario....
Agenda Introduction Scenario Methods Explanation Code Tip: Use links to go to a different page inside your presentation.
Introduction Automate a login process for e-learning website is the most interesting phase in website. Selenium WebDriver gives user a lot of options to execute the test on different browser. The login feature is the most important component of website from security point of view. BACK TO AGENDA PAGE
Scenario & steps In this test case we will pass the username and password to website to check that we will be able to login or not. 1. Click login button. Enter the username Enter the password. Click the submit button. 2. 3. 4. BACK TO AGENDA PAGE
Important Methods System.setProperty As the name suggests, the setProperty method enables QAs to set the properties for the desired browser for test automation. The system setProperty method has two attributes – “propertyName” and “value.” The propertyName represents the name of the browser-specific driver, and the value points to the path of that browser driver. driver.findElement Selenium Find Element command takes in the By object as the parameter and returns an object of type list WebElement in Selenium. WebElement WebElement represents an HTML element .It is a interface that allows the Selenium code to interact with various elements in webpage. driver.close The driver.close() command is used to close the current browser window having focus. In case there is only one browser open then calling driver.close() quits the whole browser session. BACK TO AGENDA PAGE
import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class TestCode { Code @Test void login() throws InterruptedException { System.setProperty("webdriver.chrome.chromedriver", "C://Program Files//chromedriver.exe"); ChromeDriver browserObject = new ChromeDriver (); browserObject.get("http://demo.itlearn360.com/"); browserObject.manage().window().maximize(); browserObject.manage().timeouts().implicitlyWait(10,TimeUnit.SECONDS) ; browserObject.findElement(By.xpath("//*[@id=\"loginlabel\"]")).click(); String username= "Demo"; String password="Test123456$"; WebElement email= browserObject.findElement(By.id("user_login")); email.sendKeys(username); WebElement pass= browserObject.findElement(By.id("user_pass")); pass.sendKeys(password); browserObject.findElement(By.id("wp-submit")).click(); } } BACK TO AGENDA PAGE
Contact Us +1-800-543-5571 training@infotek-solutions.com www.qaonlinetraining.com 205 Van Buren St Suite 120 Herndon Virginia 20170