0% found this document useful (0 votes)
2 views11 pages

Webdriver Base Methods: Test Automation Basics With Selenium & Java

The document provides a guide on building a test automation framework using Selenium and Java, focusing on WebDriver methods. It includes code examples for creating tests with TestNG, connecting the WebDriver executable, navigating to web pages, and managing browser sessions. Additionally, it outlines exercises for users to practice opening browsers and performing actions like refreshing pages and printing titles.

Uploaded by

sxoterry
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views11 pages

Webdriver Base Methods: Test Automation Basics With Selenium & Java

The document provides a guide on building a test automation framework using Selenium and Java, focusing on WebDriver methods. It includes code examples for creating tests with TestNG, connecting the WebDriver executable, navigating to web pages, and managing browser sessions. Additionally, it outlines exercises for users to practice opening browsers and performing actions like refreshing pages and printing titles.

Uploaded by

sxoterry
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

WebDriver base methods

Test automation basics with Selenium & Java


By:
Evgeny Novikov
Email:
xevgnov@[Link]
Let’s start framework building

By:
Evgeny Novikov
Email:
xevgnov@[Link]
Create a test with TestNG framework
import [Link]. Test;

public class SearchTest {

@Test
public void openGoogleComInChromeTest() {
}

By:
Evgeny Novikov
Email:
xevgnov@[Link]
How to connect [Link] to the project
import [Link]. Test;

import [Link];

public class SearchTest {

@Test
public void openGoogleComInChromeTest() {
File file = new File("src/test/resources/[Link]");
System. setProperty("[Link]",
[Link]());
}

}
By:
Evgeny Novikov
Email:
xevgnov@[Link]
Opening the page with WebDriver
import [Link];
import [Link];
import [Link]. Test;

import [Link];

public class SearchTest {

@Test
public void openGoogleComInChromeTest() {
File file = new
File("src/test/resources/[Link]");
System. setProperty("[Link]",
[Link]());
WebDriver driver = new ChromeDriver(); By:
[Link]().to( "[Link] Evgeny Novikov
} Email:
} xevgnov@[Link]
WebDriver instance
1) Local testing
WebDriver driver = new ChromeDriver();

WebDriver driver = new InternetExplorerDriver();

2) Remote testing
WebDriver driver = new RemoteWebDriver(remoteURL,
By:
desiredCapabilities); Evgeny Novikov
Email:
xevgnov@[Link]
Open browser, go to URL
1) To open browser page with URL address use:
[Link]().to("[Link]

or
[Link]("[Link]

2) Other methods of navigate()

back forward refresh


By:
Evgeny Novikov
Email:
xevgnov@[Link]
Close the browser

1) Close all browser windows opened under


WebDriver
[Link]();
2) Close current window is used by WebDriver
[Link]();
By:
Evgeny Novikov
Email:
xevgnov@[Link]
Open and close WebDriver
@Test
public void openGoogleOrgInChromeTest() {
File file = new File("src/main/resources/[Link]");
System. setProperty("[Link]",
[Link]());
WebDriver driver = new ChromeDriver();
[Link]().to( "[Link]
System. [Link]([Link]());
[Link]();
}

By:
Evgeny Novikov
Email:
xevgnov@[Link]
Create a new script with steps:

1. open Internet Explorer browser


● remember to set property in
[Link]() correctly to fit

Exercise browser you use:


"[Link]"
2. goes to url
Create test method with listed „[Link]
steps 3. reload the page by method refresh()
4. print page header
5. close the browser
Setup the same level of security in IE
properties:

Exercise
Create test method with listed
steps

You might also like