UrbanPro
true

Learn Selenium from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Learn Selenium with Java with Free Lessons & Tips

Ask a Question

Post a Lesson

All

All

Lessons

Discussion

Lesson Posted on 23/11/2018 Learn Selenium with Java

Why we declare WebDriver driver = new FirefoxDriver(); and not FirefoxDriver driver = new FirefoxDriver();

Srinivas Kini

*Overall having 12+ years experience in IT with various MNC's. * Automation tool experience is 10+...

Here, List or WebDriver is an Interface - a contract or set of rules created for implementing class.So, in Java, we cannot create an instance of an interface. ieI cannot say List list = new List();But classes can be instantiated. Hence,FirefoxDriver fd= new FirefoxDriver(); andArrayList list=new ArrayList();are... read more

Here, List or WebDriver is an Interface - a contract or set of rules created for implementing class.
So, in Java, we cannot create an instance of an interface. ie
I cannot say List list = new List();
But classes can be instantiated. Hence,
FirefoxDriver fd= new FirefoxDriver(); and
ArrayList list=new ArrayList();
are meaningful because both are classes in Java.
Now, coming back to the same question. When we say FirefoxDriver fd= new FirefoxDriver(); or ArrayList list=new ArrayList();
It is nothing but using specific implementation. ArrayList or FirefoxDriver. If we have code like this, then in the future, if we want to switch to
other implementations of List or WebDriver then we need to modify our complete code as there is no guarantee that the rest of the code doesn't make use of methods specific to the particular class. However, if given like this:
List list = new ArrayList();
WebDriver driver = new FirefoxDriver();
It gives the flexibility to switch implementation any time with minimal rework.
For eg: changing ArrayList to LinkedList you can change the code to List list = new LinkedList(); from List list = new ArrayList();.

read less
Comments
Dislike Bookmark

Lesson Posted on 23/11/2018 Learn Selenium with Java

Use JavascriptExecutor to do many cool things in Selenium

Srinivas Kini

*Overall having 12+ years experience in IT with various MNC's. * Automation tool experience is 10+...

Javascript is a compelling language to interact with DOM. So it would make sense to use Javascript to run in the browser using Selenium whenever there is no other way to work on a particular element using Selenium. JavascriptExecutor is an interface. By creating object JavascriptExecutor jse=(JavascriptExecutor)driver;... read more

Javascript is a compelling language to interact with DOM. So it would make sense to use Javascript to run in the browser using Selenium whenever there is no other way to work on a particular element using Selenium.

JavascriptExecutor is an interface.
By creating object JavascriptExecutor jse=(JavascriptExecutor)driver;
we can use method executeScript to execute anything in the browser using javascript.

Firstly, some of the basic things like a scroll, get URL, Title can be performed using javascript with the following code.

window.scrollBy(0,400); // x, y --> x is for horizontal scroll. y is for vertical scroll. And if you pass negative value it scrolls in other direction.

document.URL; // get URL of current browser
document.domain; // get domain of browser
document.title; // get title of the browser page.

Now, this code we can execute in selenium using.

JavascriptExecutor jse=(JavascriptExecutor)driver;
jse.executeScript("window.scrollBy(0,400);");

it would scroll down by 400 pixels from the current position.

You could also javascript returning some data such as in boolean, long, String, WebElement and using in your selenium code.

Eg:
String currentURL= jse.executeScript(""return document.URL").toString();

Similarly, you can write javascript to work on any element for that matter and call it in Selenium.

Another approach you can use with JavascriptExecutor is to use elements created to execute in Javascript.

Eg:

WebElement button=driver.findElement(By.name("Insert"));
button.click();
jse.executeScript("arguments[0].click();",button);

read less
Comments
Dislike Bookmark

Answered on 03/05/2018 Learn Selenium with Java +3 Java Core Java Java Script Training

Ishita Pandey

Tutor

Hi, If you haven't finalised yet, I am interested in being an instructor. I will be teaching the newest version of Java, Java 10. Experience - 3 yrs as Software Engineer, BTech CSE, teaching Java to school and college students since 3 yrs.
Answers 78 Comments
Dislike Bookmark

Learn Selenium from the Best Tutors

  • Affordable fees
  • Flexible Timings
  • Choose between 1-1 and Group class
  • Verified Tutors

Lesson Posted on 07/04/2018 Learn Selenium with Java +1 Selenium

Selenium Web Driver commonly used method

Sam

I have total 12.5+ years of professional experience as a Proficient as Lead and Manage QA activities...

Navigation Loading a web page in a current browser window driver.get("www.google.com") driver.navigate().to("www.google.com") driver.navigate().to("www.google.com") Move back & forward Driver.Navigate().Back() Driver.Navigate().Forward() Refresh page Driver.Navigate().Refresh() Locating... read more

Navigation

Loading a web page in a current browser window

  • driver.get("www.google.com")
  • driver.navigate().to("www.google.com")
  • driver.navigate().to("www.google.com")

Move back & forward

  • Driver.Navigate().Back()
  • Driver.Navigate().Forward()

Refresh page

  • Driver.Navigate().Refresh()

Locating web elements

By class

  • Id
    • driver.findElement(By.id(”some_id”));
  • ClassName
    • driver.findElement(By.className(”some_class_name”));
  • LinkText
    • driver.findElement(By.linkText(”Signin”));
  • PartialLinkText
    • driver.findElement(By.partiallinkText(”Sign”));
  • Name
    • driver.findElement(By.name(”password”));
  • TagName

    • driver.findElement(By.tagName(”label”));
  • CssSelector
    • Absolute path
      –driver.findElement(By.cssSelector(”html>body>div>p>input”));
    • Relative path
      –driver.findElement(By.cssSelector(”input”));
    • Classselection
      –driver.findElement(By.cssSelector(”.login”));
  • XPath
    • Absolute path
      –driver.findElement(By.xpath(”html/body/p/input”));
    • Relative path
      –driver.findElement(By.xpath(”//input”));
    • Attribute selection
      –driver.findElement(By.xpath(”//input[@id=’username’]”));

Synchronization

Page Load Timeout

  • driver.manage().timeouts(). pageLoadTimeout(30, TimeUnit.SECONDS);

Explicit Wait

  • WebDriverWaitwait = new WebDriverWait(driver, TIME_OUT); wait.until(ExpectedConditions.method);

Window Handling

Handles

  • String windowHandle= driver.getWindowHandle();                                             Iterator<String> windowIterator=browser.getWindowHandles();
  • SwitchTo : driver.switchTo().window(windowHandle);
read less
Comments
Dislike Bookmark

Lesson Posted on 02/04/2018 Learn Selenium with Java +1 Selenium

What is Selenium?

Devendra V.

I have been working as software engineer for the past 9 years. Currently associated with Opentext as...

In simple words, Selenium automates browsers. It is a robust set of tools that supports rapid development of test automation for web-based applications. Cool Features: Works on every system, where JavaScript is supported. Can simulate a user navigating through pages and then assert for specific... read more
In simple words, Selenium automates browsers. It is a robust set of tools that supports rapid development of test automation for web-based applications.
Picture
Cool Features:
  • Works on every system, where JavaScript is supported.
  • Can simulate a user navigating through pages and then assert for specific marks on the pages.
  • To automate browser actions, we should write code in JavaScript. But selenium supports multiple languages, and it will act as middleware. So, you can write tests in one of those languages. Ex: Java, C#, Perl, Ruby etc.
  • Ability to deploy on different platforms. Ex: Windows, Linux, Mac.

This fig. will give us a clear picture on supported browsers, languages and Operating systems of Selenium.

 
read less
Comments
Dislike Bookmark

Lesson Posted on 02/04/2018 Learn Selenium with Java

Difference between driver.close() and driver.quit () method

Devendra V.

I have been working as software engineer for the past 9 years. Currently associated with Opentext as...

close () -By using this command, we can close the current browser or page. quit() - By using this command, we can shut down the web driver instance or destroy the web driver instance(Close all the windows).
Comments
Dislike Bookmark

Learn Selenium from the Best Tutors

  • Affordable fees
  • Flexible Timings
  • Choose between 1-1 and Group class
  • Verified Tutors

Lesson Posted on 02/04/2018 Learn Selenium with Java

How to refresh a page without using contextclick?

Devendra V.

I have been working as software engineer for the past 9 years. Currently associated with Opentext as...

1. Using sendKeys methoddriver.findElement(By.id("firstname-placeholder")).sendKeys(Keys.F5);2. Using navigate.refresh() methoddriver.navigate().refresh();3. Using navigate.to() methoddriver.navigate().to(driver.getCurrentUrl());4. Using get() methoddriver.get(driver.getCurrentUrl()); read more

1. Using sendKeys method
driver.findElement(By.id("firstname-placeholder")).sendKeys(Keys.F5);
2. Using navigate.refresh() method
driver.navigate().refresh();
3. Using navigate.to() method
driver.navigate().to(driver.getCurrentUrl());
4. Using get() method
driver.get(driver.getCurrentUrl());

read less
Comments
Dislike Bookmark

Lesson Posted on 02/04/2018 Learn Selenium with Java

How to mouse hover on an element in webdriver

Devendra V.

I have been working as software engineer for the past 9 years. Currently associated with Opentext as...

Actions action = new Actions(webdriver);WebElement we = webdriver.findElement(By.id("email"));action.moveToElement(we).build().perform();
Comments
Dislike Bookmark

Lesson Posted on 02/04/2018 Learn Selenium with Java

How to toggle b/w windows in webdriver

Devendra V.

I have been working as software engineer for the past 9 years. Currently associated with Opentext as...

getWindowHandles will provide us handles for all windows available. Set windows = driver.getWindowHandles(); Iterate through all windows and choose suitable window based on its title for (String window : windows){ driver.switchTo().window(window); if (driver.getTitle().contains(windowTitle))... read more
getWindowHandles will provide us handles for all windows available.
Set windows = driver.getWindowHandles();
Iterate through all windows and choose suitable window based on its title
for (String window : windows)
{
       driver.switchTo().window(window);
       if (driver.getTitle().contains(windowTitle))
       {
             //do implementation
       }     
}
read less
Comments
Dislike Bookmark

Learn Selenium from the Best Tutors

  • Affordable fees
  • Flexible Timings
  • Choose between 1-1 and Group class
  • Verified Tutors

Lesson Posted on 02/04/2018 Learn Selenium with Java

How to toggle b/w frames in webdriver

Devendra V.

I have been working as software engineer for the past 9 years. Currently associated with Opentext as...

driver.switchTo().frame() method takes one of the three possible arguments: A number - Select a frame by its (zero-based) index. A name or ID - Select a frame by its name or ID. A previously found WebElement - Select a frame using its previously located WebElement. read more

driver.switchTo().frame() method takes one of the three possible arguments:

  • A number - Select a frame by its (zero-based) index.
  • A name or ID - Select a frame by its name or ID.
  • A previously found WebElement - Select a frame using its previously located WebElement.
read less
Comments
Dislike Bookmark

About UrbanPro

UrbanPro.com helps you to connect with the best Selenium Training in India. Post Your Requirement today and get connected.

Overview

Lessons 29

Total Shares  

+ Follow 16,508 Followers

You can also Learn

Top Contributors

Connect with Expert Tutors & Institutes for Selenium with Java

x

Ask a Question

Please enter your Question

Please select a Tag

X

Looking for Selenium Classes?

The best tutors for Selenium Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Selenium with the Best Tutors

The best Tutors for Selenium Classes are on UrbanPro

Book a Free Demo

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more