Thursday 6 August 2015

Selenium interview questions

How to refresh a page without using context click? 1. driver.navigate().refresh();
2. (webdriver).sendKeys(Keys.F5);
3. driver.get(URL);
What are desired capabilities?
Difference between "GET" and "NAVIGATE" to open a web page in selenium
web driver?
Get method will get a page to load or get page source or get text that's all whereas navigate
will guide through the history like refresh, back, forward.For example if we want to move
forward and do some functionality and back to the home page this can be achieved
through navigate() only. driver.get will wait till the whole page gets loaded and driver.navigate
will just redirect to that page and will not wait
Difference b/w implicitly
Wait and Explicit wait?
Difference between driver.Close()
and driver.Quit () method?
Close() - It is used to close the browser or page currently which is having the focus.
Quit() - It is used to shut down the web driver instance or destroy the web driver instance
(Close all the windows)
What is the basic use of Firefox profiles and
how can we use them using selenium?
A profile in Firefox is a collection of bookmarks, browser settings, extensions, passwords,
and history; in short, all of your personal settings.
We use them to change user agent, changing default download directory, changing versions etc.
How to get the CSS attributes from a tag? driver.findelement(By.Xpath("Xpath ").getcssvalue("font-size);
Hierarchy of TestNG annotations?
Printing functionality in selenium Case1. Any hyperlink/button on a web page, n clicking that link/button a print dialog box
opens. (Performing an action on web page)
Case2.or do u want to open print dialog box within ur own script, not by performing any
action on web page.
So If Case 1: just a call for WebElement.click() event will work to open it.
If Case 2: Call a Printer Job object (Use Awt API).
How to find broken images in a page using Selenium?
How to handle autocomplete box in web driver? Follow these steps:-
1. type partial text in text box
2. get the locator of the desired text to be selected based on the partial text entered
OR
read all elements and store it in arrayList and iterate it when the element.getText() == "your requred text", click on the element and come out of the loop
3. click on the element found in step 2
How to pass parameters from testng.xml into
test case?
Use the below code:-
@BeforeTest
@Parameters({ "BROWSER" })
public void setup(String BROWSER) {
System.out.println("Browser: " + BROWSER);
if (BROWSER.equals("FF")) {
System.out.println("Firefox Browser is selected");
driver = new FirefoxDriver();
}
How to read the text from CAPTCHA image? CAPTCHA as an acronym for "Completely Automated Public Turing test to tell Computers and Humans Apart". So, if "machine" can solve it, it's not really do it's job.
In order to solve it, there is something you can do - to use API of external services such as http://www.deathbycaptcha.com. You implementing their API, passing them the CAPTCHA and get in return the text.