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.