Selenium Interview Questions part 6
Note : You can add questions and answer in comments section after the post. We will add them to the series if not duplicated.
51) How do you perform mouse operations?
You can use the selenium class named as Actions to perform the mouse operations. You need to use methods build and perform after using the methods like click(),doubleClick() etc.
52) How do you double click on any element in a webpage?
Actions act = new Actions(driver);
act.doubleClick(element).build().perform();
53) Can we perform drag and drop operation on any element?
Yes, we can do this by using Actions class only. We need to create the source and destination webelement first.
WebElement destination = driver.findElement(By.id(“Taget ElementID”));
Actions act = new Actions(driver);
act.dragAndDrop(source, destination ).perform();
54) How do we submit a form using Selenium?
element.submit();
55) Explain how you can login into any site if it’s showing any authentication popup for password and username?
Syntax-http://username:password@url
ex- http://shekhar:[email protected]
56) What is the use of Firefox Profiling and how do we create it?
Click here for the answer..
57) How to handle internationalisation through web driver?
profile.set Preference(“intl.accept_languages”,”jp”);
Web driver driver = new FirefoxDriver(profile);
driver.get(“http:\\google.com”);
It will open google in Japanese language.
58) Can u write a code for printing in selenium?
There are two cases:
Case1. Any hyperlink/button on a web page, and clicking that link/button will open a print dialog box .(i.e. perform an action on a web page)
Case2. Open print dialog box within your own script, not by performing any action on web page.
Case 1 answer : Just a call for WebElement.click() event will work to open it.
Case 2 answer : Call a Printer Job object (Use Awt API). You can check code details here..
59) How will you work with multiple browser windows?
Click here for the answer..
60) Is there a way to click hidden LINK in web driver?
You can use javascript executor and change its css property. You can give it a try , in some cases it might not work.
JavascriptExecutor js1=(JavascriptExecutor)driver; js1.executeScript(“$(“+Block1+”).css({‘display’:’block’});”);
driver.get(“http:\\google.com”);