Java By Kiran
Java Training Institute in Pune
Java Training Institute in Pune
• Selenium WebDriver software testing tool Is well designed object oriented API which Is developed to automate web and mobile applications testing process. WebDriver API Is bigger than Selenium RC but It's Architecture Is simple and easy to understand compared Selenium RC API.
• We can automate our web application's software testing process using selenium webdriver.
• We can say it is advanced version of selenium RC software testing tool because some limitations of selenium RC has been overcome In selenium WebDriver software testing tool.
• WebDriver Is designed to provide better support for dynamic changing pages.
Example : Web page elements of software web application is changing without reloading the page. In this case WebDriver works better.
• Selenium Webdriver software testing tool Is more faster that Selenium RC software testing tool as It Is directly Interacting with web browsers and mimic the behaviour of a real user.
Example : User clicks on button of web page or moving mouse on main menu to get the sub menu list. WebDriver works Same.
• All popular browser vendors are active participants In selenium WebDriver's development and all of them have their own engineers team to Improve this framework.
Selenium WebDriver API has a many different drivers to test your web application In different browsers. List of Webdriver browser drivers are as bellow.
• Firefox Driver - For Mozilla Firefox browser
• Internet Explorer Driver - For Internet Explorer browser
• Chrome Driver - For Google Chrome browser
• HtmlUnit Driver - GUI-Less(Headless) browser for Java programs
• Opera Driver - For Opera browser
We can get support of mobile software application testing using Selenium webdriver. Selenium WebDriver supports bellow given drivers to test mobile application.
Selenium WebDriver Is very wast API and It support many different languages to write test cases for your software web application. List of WebDriver supported languages are as bellow.
Selenium WebDriver supports bellow given element locators.
• XPath Locator
• CSSSelector Locator
• ClassName Locator
• ID Locator
• Name Locator
• LinkText Locator
• PartialLinkText Locator
• TagName Locator
We can get bellow given benefits If automate our software testing process.
• Fast Test Execution : Manual software testing process Is time consuming. Automation tests are faster and takes less time to execute tests compared to manual test execution.
• Re-usability Of Test Cases : You need to prepare automation test cases only one time. Then you can use same test cases for all upcoming version release of software application. However you need to modify your test cases If there Is any flow change of business logic changes In software. But It Is less time consuming.
• Testing Cost Reduction : You have to put human efforts only one time to automate your software test process. Latter on automation tool will work for you at place of human resource.
• Better Test Coverage In Each Version Release: You have to Implement test scenarios only once In your automation test cases. Latter on you can execute same test cases In all upcoming release. So each scenarios will be tested In every version release.
• Easy For Compatibility Testing : It Is easy to run same tests In combination of different OS and browser environments using automation tools.
No. WebDriver do not have any record and playback facility. But you can record your tests In one of the selenium version called Selenium IDE and then you can export your recorded tests In webdriver compatible format as per your preferred language.
At present, Mainly bellow given operating systems support Selenium WebDriver.
• Windows - Windows XP, Windows 7, Windows 8 and Windows 8.1
• Apple OS X
• Linux - Ubuntu. Other versions of linux should support too.
All versions of selenium software testing tool are open source. You can use any version of selenium In free of charge.
I choose to use It because
• Open Source.
• It has multi-browser support.
• Multi-OS support.
• Multi types of locators support. So If one not works, We can use another type.
• Web as well mobile application testing support.
• Many testers are using selenium WebDriver to automate their testing process. So getting solution of any complex Issue very easily on Internet.
• It Is extendable and flexible.
• Continues support from WebDriver's development team to Improve the API and resolve current Issues.
Bellow given 2 java frameworks are supported by selenium WebDriver.
We can open new Mozilla Firefox browser Instance using bellow given syntax In WebDriver software testing tool.
WebDriver driver = new FirefoxDriver();
In Selenium WebDriver software testing tool, XPath is used to locate the elements. Using XPath, We can navigate through elements and attributes In an XML document to locate software webpage elements like buttons, text box, links, Images etc..
I am using Mozilla Firefox AddOns FireBug and FirePath to find the XPath of software web elements.
Absolute XPath :
Absolute XPath Is the full path starting from root node and ends with desired descendant element's node. It will start using single forward slash(/) as bellow.
Example Of Absolute XPath :
:To press ENTER key using selenium WebDriver software automation tool, We need to use selenium Enum Keys with Its constant ENTER as bellow.
There are two types of waits available In selenium WebDriver software automation testing tool.
Sometimes, Elements are taking time to be appear on software web application page. Using Implicit wait In webdriver software testing test case, We can poll the DOM for certain amount of time when some element or elements are not available Immediately on webpage.
Implicit Wait Example :
Using explicit wait code In selenium webdriver software automation testing tool, You can define to wait for a certain condition to occur before proceeding further test code execution.
Explicit Wait Example :
WebDriverWait wait = new WebDriverWait(driver, 20); wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='gbqfq']")));
You can use java.lang.Thread.sleep(long milliseconds) method to pause the software test execution for specific time. If you wants to pause your test execution for 10 seconds then you can use bellow given syntax In your test. Thread.sleep(10000);
Selenium webdriver software testing tool works like real user Interacting with software web page and Its elements. It Is using each browser's native support to make direct calls with browser for your software application under test. There Is not any Intermediate thing In selenium webdriver to Interact with web browsers.
It depends. If you are using only selenium webdriver API to run your tests and you are running your all your tests on same machine then you do not need selenium server because In this case, webdriver can directly Interact with browser using browser's native support.
You need selenium server with webdriver when you have to perform bellow given operations with selenium webdriver.
• When you are using remote or virtual machine to run webdriver tests for software web application and that machine have specific browser version that is not on your current machine.
• When you are using selenium-grid to distribute your webdriver's test execution on different remote or virtual machines.
No. It will not work and show you an exception like :
"Exception in thread "main" org.openqa.selenium.WebDriverException: f.QueryInterface is not a function" when you run your test. You need to provide http:// protocol with URL In driver.get method as bellow.
You will get this exception when WebDriver Is not able to locate element on the page of software web application using whatever locator you have used In your test. To resolved this Issue, I will check bellow given things.
• First of all I will check that I have placed Implicit wait code In my test or not. If you have not placed Implicit timeout In your test and any element Is taking some time to appear on page then you can get this exception. So I will add bellow given line at beginning of my test case code to wait for 15 seconds for element to be present on page. In 70% cases, this step will resolved Issue. View Practical Example Of Implicit Wait.
WebDriverWait wait = new WebDriverWait(driver, 25);wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#submitButton")));
No. This Is the biggest disadvantage of selenium WebDriver API. We can automate only web and mobile software application's testing using selenium WebDriver.
We can use anyone from bellow given two methods to open URL In web browser In selenium webdriver software testing tool.