Interview Questions For Selenium WebDriver Part 11

Part 11

48 : Can you tell me a syntax to close current webdriver Instance and to close all opened webdriver Instances?

Answer :
Yes, To close current WebDriver Instance, We can use Close() method as bellow.
driver.close();

If there are opened multiple webdriver Instances and wants to close all of them then we can use webdriver's quit() method as bellow in software automation test.
driver.quit();

49 : Is It possible to execute javascript directly during software test execution? If Yes then tell me how to generate alert by executing javascript In webdriver script?

Answer :
Yes, we can execute javascript during webdriver software test execution. To generate alert, You can write bellow given code In your script.
JavascriptExecutor javascript = (JavascriptExecutor) driver;
javascript.executeScript("alert('Javascript Executed.');");

VIEW DIFFERENT EXAMPLES to see usage of WebDriver's JavascriptExecutor.

50 : Give me a syntax to read javascript alert message string, clicking on OK button and clicking on Cancel button.

Answer :
We can read alert message string as bellow.
String alrtmsg = driver.switchTo().alert().getText();

We can click on OK button of alert as bellow.
driver.switchTo().alert().accept();

We can click on Cancel button of alert as bellow.
driver.switchTo().alert().dismiss();

VIEW PRACTICAL EXAMPLE to handle alert, Confirmation And Prompt popups.

51 : Tell me a scenario which we can not automate In selenium WebDriver.

Answer :
1. Bitmap comparison Is not possible using selenium webdriver software testing tool.
2. Automating captcha Is not possible. (Few peoples says we can automate captcha but I am telling you If you can automate any captcha then It Is not a  captcha).
3. We can not read bar code using selenium webdriver software testing tool.

52 : What Is JUnit?

Answer : Java software developers use JUnit as unit testing framework to write repeatable tests for java programming language. It Is very simple and open source framework and we can use It In selenium webdriver test scripts creation to manage them In well manner.



No comments:

Post a Comment