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?
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.
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")));
26 : Can we automate desktop software application's testing
using selenium WebDriver?
Answer : No. This Is the biggest disadvantage of selenium
WebDriver API. We can automate only web and mobile software application's
testing using selenium WebDriver.
27 : Can you tell me the alternative driver.get() method to
open URL In browser?
Answer : We can use anyone from bellow given two methods to
open URL In web browser In selenium webdriver software testing tool.
1.
driver.get()
2.
driver.navigate().to()
28 : Can
you tell me a difference between driver.get() and driver.navigate()
methods?
Answer : Main and mostly used functions of both methods are as
bellow.
driver.get()
driver.get()
- driver.get()
method Is generally used for Open URL of software web application.
- It
will wait till the whole page gets loaded.
driver.navigate()
- driver.navigate()
method Is generally used for navigate to URL of software web
application, navigate back, navigate forward, refresh the page.
- It
will just navigate to the page but wait not wait till the whole
page gets loaded.
29 : WebDriver has built In Object Repository. Correct me If
I am wrong.
Answer : No. WebDriver do not have any built In object
repository till now. But yes, I am using java .properties file In my framework
to store all required element objects In my tests. View Example.
30 : Can you tell me syntax to set browser window size to
800(Width) X 600(Height)?
Answer : We can set browser window size using setSize method of selenium webdriver software testing tool. To set size
at 800 X 600, Use bellow given syntax In your test case.
driver.manage().window().setSize(new Dimension(500,500));