Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
What are the most basic steps to write a web driver script?
The most basic steps to write a web driver script are listed below −
Open any browser by creating a webdriver reference pointing to the corresponding browser driver class.
Launch any URL with the get() method.
Pause for some time for the page load.
Confirm that we are on the correct web page.
Finally close the session.
Code Implementation
Example
import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import java.util.concurrent.TimeUnit;
public class WebScripting {
public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");
WebDriver driver = new ChromeDriver();
String url = "https://www.tutorialspoint.com/index.htm";
// launching the URL
driver.get(url);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
System.out.println("Page loaded successfully");
driver.close();
}
} Advertisements
