Find the best tutors and institutes for QA

Find Best QA Training

Please select a Category.

Please select a Locality.

No matching category found.

No matching Locality found.

Search for topics

QA Updates

Ask a Question

Post a Lesson

All

All

Lessons

Discussion

Lesson Posted on 23 Nov IT Courses/QA/Selenium/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

Lesson Posted on 23 Nov IT Courses/QA/Selenium/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

Answered on 25 Jul IT Courses/QA/Automation Testing

Harini S.

Hi, The course fee for Automation Specialists Level 1 is 6000rs. Time -12hrs
Answers 3 Comments 1
Dislike Bookmark

Looking for QA Training

Find best QA Training in your locality on UrbanPro.

FIND NOW

Answered on 03 May IT Courses/Java IT Courses/Java/Core Java IT Courses/Java Script Training +1 IT Courses/QA/Selenium/Selenium with Java less

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

Answered on 09 Jun IT Courses/QA/Selenium

Shalini Raman

Trainer

Hi, I am 8.5 yrs in it industry in automation.i will give all kind of practical experience. With regards Shalini
Answers 6 Comments 1
Dislike Bookmark

Lesson Posted on 07 Apr IT Courses/QA/Selenium IT Courses/QA/Selenium/Selenium with Java

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

Looking for QA Training

Find best QA Training in your locality on UrbanPro.

FIND NOW

Answered on 25 Jan IT Courses/QA/Selenium

Arun Sharma

Tutor

As a beginner level you should have some meaningful idea of some basic terminologies and their functional behaviors like classes, data types or methods. Once you start understanding these, then you can jump on the concept of OOPS and can start your selenium learning simultaneously so that you can correlate... read more

As a beginner level you should have some meaningful idea of some basic terminologies and their functional behaviors like classes, data types or methods. Once you start understanding these, then you can jump on the concept of OOPS and can start your selenium learning simultaneously so that you can correlate your learning with the practical and hands on work. In case of any more doubt, you can contact me on my number. We can have a discussion.

read less
Answers 3 Comments
Dislike Bookmark

Answered on 09 Feb IT Courses/QA/Selenium

Geetha

Teacher

By id
Answers 3 Comments
Dislike Bookmark

Answered on 25 Apr IT Courses/QA/Selenium

Mindmajix Technologies INC

Selenium is good to learn. It has good future. Learn selenium automation & expertise in using Selenium 3.0 to create robust, browser-based regression automation suites and tests, scale and distribute scripts and create quick bug reproduction scripts. You will master selenium IDE, Selenium webDriver,... read more

Selenium is good to learn. It has good future. Learn selenium automation & expertise in using Selenium 3.0 to create robust, browser-based regression automation suites and tests, scale and distribute scripts and create quick bug reproduction scripts. You will master selenium IDE, Selenium webDriver, JaCoCo, TestNG, Sikuli, Page Object Modeling and Optimize XPath with Xpather and Selenium RC. You will also get an exposure to industry based real-time projects in various verticals.

 

Mindmajix provides best Selenium online training. Training by real time experts. Schedule and attend free online demo here! https://mindmajix.com/selenium-training

read less
Answers 4 Comments 1
Dislike Bookmark

Looking for QA Training

Find best QA Training in your locality on UrbanPro.

FIND NOW

Answered on 14 Mar IT Courses/QA/Selenium

Nisha K.

Selenium Trainer

Yes, it is an awesome career option and it will add value too. I saw people from Manual Testing upgraded themselves to Selenium. If you want to make career in Automation Testing field, then Selenium is the best option for you.Selenium, the most popular automated testing technology, is open source and... read more

Yes, it is an awesome career option and it will add value too. I saw people from Manual Testing upgraded themselves to Selenium. If you want to make career in Automation Testing field, then Selenium is the best option for you.
Selenium, the most popular automated testing technology, is open source and free of charge.

read less
Answers 8 Comments
Dislike Bookmark

About UrbanPro

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

Overview

Questions 460

Lessons 65

Total Shares  

+ Follow 5,207 Followers

Related Topics

Top Contributors

Connect with Expert Tutors & Institutes for QA

x

Ask a Question

Please enter your Question

Please select a Tag

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 25 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 6.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