What is GeckoDriver
Gecko is a web browser engine developed by Mozilla. Link between Selenium tests and gecko-based browsers, such as Firefox and other applications.
What is GeckoDriver
Gecko is a web browser engine developed by Mozilla. Link between Selenium tests and gecko-based browsers, such as Firefox and other applications.
We going to create the Frist Test case in Selenium Webdriver. following steps to create a Test case.
Required:
Step1: Initialize Webdriver
System.setProperty java system property is a key-value pair. Each browser has its own WebDriver implementation. Selenium to interact with the browser-specific driver we need to specify the driver and path of the driver.
WebDriver is the Interface which contains all the Selenium method signatures like findElement(), switchTo(), get() etc.
the driver is a reference variable, ChromeDriver() is a Constructor, new is a keyword and new ChromeDriver() is an Object.
Step2: Launch Webpage using WebDriver
We can use navigation between the pages back, forward and refresh.
3. Close Webdriver
Sample Code:
package DemoTestCase;
import org.openqa.selenium.By;
public class FirstTestCase {
public static void main(String args[]) {
System.setProperty("webdriver.chrome.driver", "C:\\Users\\RMJ\\eclipse-workspace\\SeleniumFirstTestCase\\Drivers\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.navigate().to("http://www.google.com/");
driver.findElement(By.id("lst-ib")).sendKeys("javatpoint tutorials");
driver.findElement(By.name("btnK")).click();
}
}
Select is a class in SeleniumWebdriver which is used to Select and Deselect in a Dropdown List element.
WebElement country= driver.findElement(By.id("drpCountry"));
Select dropdown = **new** Select(country);
| ID | driver.findElement(By.Id("Login")); |
| Name | driver.findElement(By.Name("Login")); |
| ClassName | driver.findElement(By.ClassName("Login")); |
| LinkText | driver.findElement(By.LinkText("Login")); |
| PartialLinkText | driver.findElement(By.PartialLinkText("Login")); |
| TagName | driver.findElement(By.TagName("Login")); |
| XPath | driver.findElement(By.XPath("Login")); |
driver.findElement(By.xpath("//*[@Value='Yes']")).click();