Part 5
21 : How does selenium RC software testing tool drive the browser?
Answer :
When browser loaded In Selenium RC, It ‘injected’ javascript functions into the browser and then It Is using javascript to drive the browser for software application under test.
When browser loaded In Selenium RC, It ‘injected’ javascript functions into the browser and then It Is using javascript to drive the browser for software application under test.
22 : How does the selenium WebDriver drive the browser?
Answer : 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.
VIEW MORE TUTORIALS on selenium WebDriver.
VIEW MORE TUTORIALS on selenium WebDriver.
23 : Do you need Selenium Server to run your tests In selenium WebDriver?
Answer : 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.
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.
24 : Bellow given syntax will work to navigate to specified URL In WebDriver? Why?
You need to provide http:// protocol with URL In driver.get method as bellow.
driver.get("www.google.com");
Answer : 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.
driver.get("http://www.google.com");
Now It will work.
25 : Tell me a reason behind bellow given WebDriver exception and how will you resolve It?
"Exception in thread "main" org.openqa.selenium.NoSuchElementException: Unable to locate element"
Answer : 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.
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
- Another reason behind this Issue Is element's ID Is generated dynamically every time when reloading the page. If I have used element's ID as an element locator or used It In xpath to locate the element then I need to verify that ID of element remains same every time or It Is changing? If It Is changing every time then I have to use alternative element locating method. In 20% cases, This step will resolve your Issue.
- If Implicit wait Is already added and element locator Is fine then you need to verify that how much time It(element) Is taking to appear on page. If It Is taking more than 15 seconds then you have to put explicit wait condition with 20 or more seconds wait period as bellow. In 5 to 10% cases, This step will resolve your Issue. View Example.
WebDriverWait wait = new WebDriverWait(driver, 25);
wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#submitButton")));
No comments:
Post a Comment