Selenium Interview Q & A - Part 2
Selenium Interview Q & A - Part 2
Telegram Group:
https://t.me/joinchat/Bv_U1ZHC-5thNmFl
Facebook Page:
https://www.facebook.com/haradhanautomationlibrary
Facebook Group:
https://www.facebook.com/groups/995593230934871
LinkedIn Profile:
https://www.linkedin.com/in/haradhan-pal-181a8326/
Agenda
Selenium WebDriver Interview
Question & Answer – 26-50 (Part 2,
Set of 25 Q&A)
Q26: What are the API commands we can use for a
Brower using Selenium Web Driver?
Navigate to the required given web page - get()
driverObject.get(“URL”); Example: driver.get(“https://www.google.co.in”);
Close all Browsers which are opened by WebDriver during test execution - quit()
driverObject.quit(); Example: driver.quit();
❑ Implicit Wait: Implicit waits are used to provide a default waiting time
between each consecutive test step/command across the entire test
script. Thus, the subsequent test step would only execute when that
have elapsed after executing the previous test step/command.
Syntax: driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
❑ Explicit Wait : Explicit wait is used to pause the execution until the time
a particular condition is met or the maximum time has elapsed. Explicit
waits are applied for a particular instance only.
❑ CSS selector is used by browsers to target specific HTML elements and apply
styles. For web browser automation, Selenium webdriver uses CSS selectors to
locate and perform an action on an object instead of applying a style.
WebElement itemtext =
driver.findElement(By.xpath("//*[contains(text(),'Sele
nium webdriver’)]"));
action.dragAndDrop(source_locator,
target_locator).build().perform();
Q46: How to enter value in a text field without
calling the sendKeys()?
JavascriptExecutor js =
(JavascriptExecutor)webdriver;
js.executeScript("document.getElementById(UserID').
value=‘[email protected]'");
JS.executeScript("document.getElementById('Passwor
d').value='‘Test123");
Q47: How to launch the Chrome browser?
System.setProperty("webdriver.chrome.driver","chrom
e.exe file path");
System.setProperty("webdriver.ie.driver","
iedriver.exe file path");
driver.get("https://www.google.com/");
Q49: What is the difference between single and
double slash in X-path?
Single slash ‘/ ’:
Single slash ( / ) start selection from the document
node
It allows you to create ‘absolute’ path expressions
Double Slash ‘// ’:
Double slash ( // ) start selection matching anywhere
in the document
It enables to create ‘relative’ path expressions
Q50: How to perform double click in Selenium
WebDriver?