Sunday, March 5, 2017

Protractor Training Curriculum


Protractor Training Curriculum

SNo.
 Topic
1  Introduction to Protractor
2  Pre-requisites Setup
3  Configure Project in Eclipse 
4  Running the first Protractor Test
5  Understanding the Conf.js file
6  Describe and It blocks for writing test cases
7  Handling Dropdown list
8  Adding validations using Jasmine Expect
9  Handle Autosuggestions
10  Introduction to Jasmine and basic features
11  About AngularJS Locators
12  Reading data and locators through JSON files
13  Jenkins configuration
14  Page Object Model - Framework (Live Project)

Register for the course at https://goo.gl/forms/Ql4ecnYktPIZlcRs2



Monday, August 8, 2016

What are different Implementing Classes available for WebDriver?

If you have experience of around 2 years in automation testing then is one of the most common question you may be asked in interview

Here's the answer :

  • ChromeDriver
  • EdgeDriver
  • OperaDriver
  • FirefoxDriver
  • InternetExplorerDriver
  • SafariDriver
  • RemoteWebDriver
  • EventFiringWebDriver

     In interview you should be able to name 5-6 WebDriver Implementing Classes.         

Tuesday, August 2, 2016

Difference between Webdriver get() and Webdriver navigate()

GET will wait till the whole page gets loaded i.e. the on-load event has fired before returning control to our test or script.

Note : If there many ajax calls in the current page which webdriver is loading, then webdriver may not know when it has loaded completely. That time to make sure pages are fully loaded then you need to use " wait " .

Navigate will just redirect to our required page and will not wait.


get() navigate()
Waits till complete page loads. Will not wait until the page loads, you can feel this experience only if page takes time to load, like more number of images or ajax calls etc......
We can not perform forward, backward & refresh operation in the browser. We can perform forward, backward & refresh operation in the browser


NAVIGATE() Method

driver.navigate().back(); // Perform backward function of browser
driver.navigate().forward();  // Perform forward function of browser
driver.navigate().refresh(); //refresh the browser

Difference between Absolute (“/”) and Relative (“//”) in Xpath?



Absolute Xpath => Single Slash “/” – Single slash is used to create Xpath with absolute path i.e. the xpath would be created to start selection from the document node/start node.

 Absolute xpath: /html/body/div[2]/div/div/footer/section[3]/div/ul/li[3]/a

Relative Xpath => Double Slash “//” – Double slash is used to create Xpath with relative path i.e. the xpath would be created to start selection from anywhere within the document.



 Relative xpath: //body//section[3]/div/ul/li[3]/a


Absolute xpaths are prone to more regression as slight change in DOM makes them invalid or refer to a wrong element

Sunday, July 31, 2016

Technique to refresh or reload a page using selenium webdriver

Here are the 5 different ways, using which we can refresh a webpage.

1. Refresh command: One of the most used and simple command for refreshing a webpage.

driver.get("https://google.com");  
driver.navigate().refresh();

2. To command: Using navigate( ).to( ) command we will be doing trick getCurrentUrl() command.

driver.get("https://google.com");  
driver.navigate().to(driver.getCurrentUrl());

3. Get command: This is a tricky one, as it is using another command as an argument to it. If you look carefully, it is just feeding get command with a page url

driver.get("https://google.com");
driver.get(driver.getCurrentUrl());

4. SendKeys command: In this SendKeys command instead of using Key, it is using ASCII code.

driver.get("https://google.com");
driver.findElement(WebElement element).sendKeys("\uE035");


\uE035 is the ASCII code of F5 key.
5. SendKeys command: Second most commonly used command for refreshing a webpage. As it is using a send keys method, we must use this on any Text box on a webpage.
driver.get("https://google.com");
driver.findElement(By.id("firstname-placeholder")).sendKeys(Keys.F5);

Friday, July 29, 2016

How to Select a Dropdown

You all are wondering  how to select/deselect a drop-down value with Selenium WebDriver 

First of all we need to import Select class
1
import org.openqa.selenium.support.ui.Select;
Here the glimpse how we are going to use Select class
1
Select dropdown = new Select(driver.findElement(By.id("identifier")));
Let’s consider the following drop-down example:
<select id="mySelect">
<option value="option1">Apple</option>
<option value="option2">Mango</option>
<option value="option3">Orange</option>
</select>

1. Identify the select HTML element:

1
2
WebElement mySelectElement = driver.findElement(By.id("mySelect"));
Select dropdown= new Select(mySelectElement);
or pass it directly to the Select element:
1
Select dropdown = new Select(driver.findElement(By.id("mySelect")));

2. To select an option you can do:

All select/deselect methods will throw NoSuchElementException if no matching option elements are found.
Select by Visible Text (select all options that display text matching the argument):
1
dropdown.selectByVisibleText("Apple");
or
Select by Index (select the option at the given index. This is done by examining the “index” attribute of an element, and not merely by counting):
1
dropdown.selectByIndex(2);
or
Select by Option Value (select all options that have a value matching the argument)
1
dropdown.selectByValue("option2");

3. To deselect an option you can do:

Also, the deselect method will throw UnsupportedOperationException if the SELECT does not support multiple selections
Deselect all selected entries, valid only when the SELECT supports multiple selections:
1
dropdown.deselectAll();
Deselect by Visible Text:
1
dropdown.deselectByVisibleText("Apple");
Deselect by Index
1
dropdown.deselectByIndex(2);
Deselect by value:
1
dropdown.deselectByValue("option2");

4. In order to get the selected option:

1
2
3
4
5
6
WebElement mySelectElement = driver.findElement(By.id("mySelect"));
Select dropdown= new Select(mySelectElement);
dropdown.selectByVisibleText("Apple");
WebElement option = dropdown.getFirstSelectedOption();
System.out.println(option.getText()); //output "Apple"

5. In order to get the list of options from a drop-down element:

1
2
3
4
5
6
WebElement mySelectElement = driver.findElement(By.id("mySelect"));
Select dropdown= new Select(mySelectElement);
List options = dropdown.getOptions();
for (WebElement option : options) {
System.out.println(option.getText()); //output "option1", "option2", "option3"
}