Wednesday, 12 September 2018

Selenium 4 is on its way!!

Recently Simon Stewart (Founder of Selenium) announced the Selenium 4 release on Christmas 2018.

So let us see whats coming up with Selenium 4!!

  1. W3C compliant 
  2. Better Selenium Grid
  3. Selenium IDE for Chrome

Note that upgrading to selenium 4 should not affect your code as it has architectural changes and all the end APIs would remain same. However the Selenium grid usage would become hassle free and must easier to use.

Wednesday, 22 August 2018

Some Coding interview question sasked in Apple interview

1. Find if a string is an anagram of another


public class anagram {

public static void main(String[] args) {
// TODO Auto-generated method stub

boolean isAnagram=false;
String str1="armys";
String str2="marsy";
char[] c1= str1.toCharArray();
char[] c2= str2.toCharArray();
if(str1.length()!= str2.length()){
isAnagram=false;
}else{
Arrays.sort(c1);
Arrays.sort(c2);
for(int i=0;i<c1.length;i++){
if(c1[i] ==c2[i]){
isAnagram=true;
}
}
}
if(isAnagram){
System.out.println("Is anagram");
}else{
System.out.println("Not anagram");
}
}

}







2. Write a program that finds out 2 numbers adds up to a value java


public class sumOf {

public static void main(String[] args) {
// TODO Auto-generated method stub
int n=5;
int[] arr= new int[n];
for (int i=1; i<=n;i++){
arr[i-1]=i;
}
for(int i=0;i<arr.length;i++){
for(int j=0;j<arr.length;j++ ){
int sum=arr[i]+arr[j];
if(sum == n){
System.out.println("Numbers are "+ arr[i] + " " + arr[j]);
}
}
}

}

}

Tuesday, 3 January 2017

Selenium Interview Questions and Answers

Listing down some of the links for Interview questions and answers for Selenium webdriver
Please feel free to add more under the comments.

1. http://www.techbeamers.com/category/interview-questions/selenium-interview/
2. https://www.linkedin.com/pulse/selenium-real-time-interview-questions-answers-technologies-13600-
3. https://intellipaat.com/interview-question/selenium-interview-questions/

Working with Dropdowns with selenium

// small example to demonstrate working with selenium webdriver and drop downs
package selenium.dropdowns;import java.util.Iterator;import java.util.List;import org.openqa.selenium.By;import org.openqa.selenium.WebElement;import org.openqa.selenium.chrome.ChromeDriver;import org.openqa.selenium.support.ui.Select;public class dd { public static void main(String[] args) throws InterruptedException {  System.setProperty("webdriver.chrome.driver", "C:\\Users\\shama.ugale\\Downloads\\chromedriver.exe");  ChromeDriver driver= new ChromeDriver();     driver.get("https://www.commonfloor.com/agent/login?show_signup=1");    WebElement cityDD=driver.findElement(By.id("city"));    ///////// use case 1 - select any elem in the dd  Select sec= new Select(cityDD);    sec.selectByIndex(45);  Thread.sleep(2000);    // this is the value attribute of the option element under ur dropdown  sec.selectByValue("Ghaziabad");  Thread.sleep(2000);    sec.selectByVisibleText("Pune");      ///////////// use case 2 -- fetch all the dd elements          List<WebElement> cities= sec.getOptions();    Iterator<WebElement> it= cities.iterator();  while(it.hasNext()){   WebElement elem= it.next();   System.out.println(elem.getText());  }    //////////////// use case 3 --- size of the elements    System.out.println("No of cities : " + cities.size());      /////////////// use case 4 -- fetch wats selected in the dd    String selectedValue=sec.getFirstSelectedOption().getText();    System.out.println("Selected option : "+ selectedValue);               }}

Practice Sites for Selenium

I know most of the people who are new to Selenium are looking for sites to practice selenium which have all kinds of scenarios such as hovering, multi-level hovering, drag and drop , resizable text fields multi select drop downs, frames, multiple windows and so on.

My suggestion is to automate anything that you would see or do day in day out to practice or to help you in your regular repeated work ;)

For example, automate your timesheets (great time saver , isn't it + its pretty boring ;) ,no offence thought).

But,i thought i would share what i have found so far. Below are some of them, please feel free to suggest more in the comments.

1. http://www.seleniumframework.com/demo-sites/
2. http://store.demoqa.com
3. http://demoqa.com
4. http://toolsqa.com/automation-practice-form/
5. http://toolsqa.com/automation-practice-switch-windows/
6. http://toolsqa.com/automation-practice-table/
7. http://toolsqa.com/handling-alerts-using-selenium-webdriver/
8. http://toolsqa.com/iframe-practice-page/
9. http://newtours.demoaut.com
10. http://thedemosite.co.uk
11. http://phptravels.com/demo/
12. http://www.way2automation.com/demo.html
13. http://automationpractice.com/index.php
14. https://enterprise-demo.orangehrmlive.com/symfony/web/index.php/auth/login

I hope these are enough to master selenium by more and more practice.

Saturday, 31 December 2016

Automation - Myths and Truths

TEST AUTOMATION IS SIMPLE, THAT EVERY TESTER CAN DO IT

 This myth is promoted by the tool sales people. They are trying to promote the following test automation process: 
 - Record the script 
 - Enhance the script by adding functions and data driving
 - Run the scripts
 - Report results 

 Under the influence of this myth the QA manager can proudly report: All our testers are developing test automation.

REALITY - TEST AUTOMATION IS A SOFTWARE DEVELOPMENT TASK 

 Automation should be designed, developed and tested  You need to have some kind of a programming background to implement test automation. Test Automation is not as complex as C++/C#/Java development.  Test automation standards should be developed  Automated test components are assets that should be treated like application source code

Highlighting Elements under Action with Selenium

We can highlight the WebElements under action during the execution to help capture them while failure analysis.

It can be done using the below code.

Have the utility function in for framework ,use it for all the actions performed at the framework level. See the sample below.

Function to highlight the WebElement under execution:

public static void elementHighlight(WebElement element) {
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("arguments[0].setAttribute('style',arguments[1]);,
element"color: red; border: 3px solid red;");

}


Use it as below, used in the plain function here, you need to embed it in your framework as to highlight all the elements under action.

public static void main(String[] argsthrows InterruptedException {
        System.setProperty("webdriver.gecko.driver","Path to geckodriver");
drivernew FirefoxDriver();
driver.get("http://www.google.com");
        WebElement searchBox = driver.findElement(By.name("q"));
elementHighlight(searchBox);
searchBox.sendKeys("Test");
WebElement searchBtn = driver.findElement(By.name("//button"));
searchBtn.click();
}

In the above example i am using Selenium 3.0.1 jars.
Note: If you are using Selenium 2.x version skip the below line from above code.
System.setProperty("webdriver.gecko.driver","Path to geckodriver");