Techlistic: Selenium Webdriver - Browser and Navigation Commands
Techlistic: Selenium Webdriver - Browser and Navigation Commands
Selenium | Java | Rest API | Postman | JMeter | Automation Tutorials & Tools | Top
Selenium Blogs | Software Testing | Python | Hacking | Guest Blogs | Webinars | Coding
Interview Q&A
HOME
SELENIUM
JAVA
DEMO SITES
ASSIGNMENTS
INTERVIEWS
REST API
TESTNG
CONTACT
JMETER
1. Browser Commands
i. Set Path of browser/driver executable:
System.setProperty("webdriver.gecko.driver",
driver_executable_path);
// For Safari
WebDriver driver = new SafariDriver();
// For Opera
WebDriver driver = new OperaDriver();
// For IE
WebDriver driver = new InternetExplorerDriver();
iii. Open URL
// Open URL
driver.get("https://www.techlistic.com/");
// Or
String url = "https://www.techlistic.com/";
driver.get(url);
// Get Title
driver.getTitle();
// Or
String sourceCode = driver.getPageSource();
// Maximize Browser
driver.manage().window().maximize();
package com.techlistic.selenium;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
// Expected Title
String expectedTitle = "Techlistic";
// Maximize Window
driver.manage().window().maximize();
// Close Browser
driver.close();
These commands are used to move forward and back using browser history.
/***********************************
* Browser Navigation Commands *
***********************************
*/
// Navigate Forward
driver.navigate().forward();
// Navigate Back
driver.navigate().back();
// Refresh Page
driver.navigate().refresh();
Selenium Webdriver
Comments
1.
Excellent. Content Simplified in its best way. Please post on pending areas in the index.
REPLY
2.
REPLY
Post a Comment
Popular Posts
Top 10 Demo Websites to Practice Selenium Webdriver Online
- February 27, 2020
In this post you will find links of top demo websites/pages which Automation
Professionals can use for practice purpose. Here is the list of demo websites:
1. AUTOMATION PRACTICE FORM Level - BeginnerAbout - This form contains all the
important form elements which we come across daily like text box, radio button, check
box, select drop downs, multi-select box, button, links, File Upload, Download link.
Sometimes we don't want to take screenshot of the full screen. Reasons might be, full
size images would last in huge memory storage for image directory or…
READ MORE
Automation Framework Building 1st step - Implementing Code Re-
usablility
- July 23, 2019
In this post, you will learn kind of coding pattern which is very helpful in maintaining our
automation code. This post is written insight to help beginners. We'll learn that instead of
writing a linear script, we should create page (action) methods which in general contain
actions which we are going to perform on our web software.
Let's say, we have a login functionality in our software and we have to automate it. In
that case we'll create a method named login and write the commands like, entering
username, password and click login in that method. Now we can use that method
wherever we need it in other test cases as well. Benefits of using action methods are:
You can also place these action methods in some other class like Common.java. And if
you want to re-use any of the methods in your Selenium script, just create the object
Comm…
READ MORE
Top 25 Must to know Selenium Webdriver Commands List
- August 20, 2019
It covers almost all selenium webdriver commands with syntax. This tutorial acts as your
guide to all important Selenium Webdriver commands.
Followers
Selenium Links
Selenium Tutorials
TestNG Integration
Blogs/Articles
Practice Assignments
Demo Websites
Interview Q/A
Online Training
Website Links
Tech Trends
Java Blogs
Python
Hacking
Selenium IDE
Guest Posts
Tutorials List
Software Testing
Java Tutorial
Selenium Tutorial
TestNG Tutorial
Labels