Job Interview Questions For Selenium WebDriver With Answers

Part 4

16 : How to press ENTER key button on text box In selenium webdriver?
Answer : To press ENTER key using selenium WebDriver software automation tool, We need to use selenium Enum Keys with Its constant ENTER as bellow.
driver.findElement(By.xpath("//input[@id='gbqfq']")).sendKeys(Keys.ENTER);

17 : How many types of waits available In selenium WebDriver
Answer : There are two types of waits available In selenium WebDriver software automation testing tool.
  1. Implicit Wait
  2. Explicit Wait
VIEW TUTORIALS on Implicit and Explicit Waits with practical examples detailed description.

18 : What Is Implicit Wait In Selenium WebDriver?
Answer : 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 :
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
If you will write above syntax In your test, Your WebDriver test will wait 10 seconds for appearing element on page.

19 : What Is Explicit Wait In Selenium WebDriver?
Answer : 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']")));
Above code will wait for 20 seconds for targeted element to be displayed and enabled or we can say clickable.

20 : I wants to pause my test execution for fix 10 seconds at specific point. How can I do It?
Answer : 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);


1 comment: