Automation testing
- Difference between Selenium web driver, Selenium IDE and Selenium Grid:
Functionalities | Selenium IDE | Selenium RC | Selenium Webdriver |
Record and playback | It has the record and playback feature. | It does not have a record and playback. | It does not have a record and playback. |
Server | It requires no server to start execution of test cases. | It requires the server to start execution of test cases. | It requires no server to start execution of test cases. |
Browser | It can be used for testing only in Firefox. | It can be used for testing in the majority of browsers. | It can be used for testing in the majority of browsers including in headless mode. |
Object Oriented | It is based on Selenese which is a procedural language. | It can be partially used for object oriented programming. | It is majorly used for object oriented programming. |
Dynamic Locators | Elements cannot be identified. | Elements cannot be identified. | Elements can be identified. |
Alerts | Cannot handle alerts. | Cannot handle alerts. | Can handle alerts |
Mouse Actions | Cannot handle mouse actions. | Cannot handle mouse actions. | Can handle mouse actions. |
Dropdown | Cannot handle dropdown. | Cannot handle dropdown. | Can handle dropdown. |
iPhone/Android | Cannot perform iPhone/Android testing. | Cannot perform iPhone/Android testing. | Can perform iPhone/Android testing with the help of Android Driver, iPhone Driver. |
Listener | Does not have a Listener. | Does not have a Listener. | Have Listeners. |
Performance | Fast [comes as a Firefox plugin]. It interacts with the browser directly. | It does not interact with the browser directly. Hence on a slower side compared to webdriver. | Fast as it interacts directly with the browser. |
Architecture | Derived from Javascript. | Derived from Javascript. | Not derived from Javascript. |
Usage | UI interface available to create scripts. | Standalone Jars available to execute test cases in the browser. | Contains API and supported by languages like Java, Python, and Ruby and so on. |
Xpath | Only has absolute xpath. | Only has absolute xpath. | Has both absolute and relative xpath. |
Navigation | Cannot handle navigation. | Cannot handle navigation. | Can handle navigation. |
- Selenium java script to open google and search "Selenium browser driver":
public static void main(String[] args) throws IOException {
//open firefox browser
WebDriver Driver = new ChromeDriver();
//opens the below url
Driver.get("https://www.google.com");
//maximize the window
Driver.manage().window().maximize();
//Take screenshot screenshot(Driver);
Driver.findElement(By.className("gLFyf")).sendKeys("Selenium browser driver"); WebElement ele = Driver.findElement(By.xpath("//span[text()='selenium browser drivers']/parent::div"));
Select objSelect =new Select(ele);
objSelect.selectByIndex(0);
}}
3.Selenium and it uses:
Selenium is an open-source suite of tools and libraries that is used for browser automation. Selenium us used to: It allows users to test their websites functionally on different browsers. Perform Cross browser testing to check if the website functions consistently across different browsers.
Selenium supports Functional Testing. As per Selenium's official website, “it supports Functional Testing at the System Testing Level and the Acceptance Testing Level of the Software Development Life Cycle”. Selenium automates the functional tests at the UI layer of the Web application under test.
Browser driver used in selenium:
AndroidDriver
ChromeDriver
FirefoxDriver
InternetExplorerDriver
IPhoneDriver
SafariDriver
Steps to create simple web driver script:
//open firefox browser
WebDriver Driver = new ChromeDriver();
//opens the below url
Driver.get("https://www.google.com");
//maximize the window
Driver.manage().window().maximize();