201) What is the selenium’s recording language?

Selenium’s recording language is “HTML”.

202) . What does it mean to be “developer focused”?

We believe that within a software application’s development team, the people who are best placed to build the tools that everyone else can use are the developers. Although it should be easy to use WebDriver directly, it should also be easy to use it as a building block for more sophisticated tools. Because of this, WebDriver has a small API that’s easy to explore by hitting the “autocomplete” button in your favorite IDE, and aims to work consistently no matter which browser implementation you use.

203) What are the steps to run automation using selenium?

The very basic steps are: Record the test steps using selenium-IDE. Modify the script according to the testing needs. Add validation points, Java Scripts, Time-out etc.

204) What are the annotations used in TestNG ?
@Test, @BeforeSuite, @AfterSuite, @BeforeTest, @AfterTest, @BeforeClass, @AfterClass, @BeforeMethod, @AfterMethod.

205)Which all browsers are supported by selenium webdriver?

Some commonly used browsers supported by selenium are-

  • Google Chrome - ChromeDriver
  • Firefox - FireFoxDriver
  • Internet Explorer - InternetExplorerDriver
  • Safari - SafariDriver
  • HtmlUnit (Headless browser) - HtmlUnitDriver
  • Android - Selendroid/Appium
  • IOS - ios-driver/Appium

206). What are various ways of locating an element in selenium?

The different locators in selenium are-

  • Id
  • XPath
  • cssSelector
  • className
  • tagName
  • name
  • linkText
  • partialLinkText

207)What is the difference between single slash(/) and double slash(//) in XPath?

In XPath a single slash is used for creating XPaths with absolute paths beginning from root node.
Whereas double slash is used for creating relative XPaths.

208) What is firebug?

Firebug is a plugin of firefox that provides variuos development tools for debugging applications. From automation perspective firebug is used to inspect elements for writing their locators.

209) What is firepath?

Firepath is fireug extension that is specifically used for generating XPaths of the elements directly.

210) Write the basic syntax for locating element using XPaths?

The basic syntax for locating element using XPaths is-

XpathExpression = //tagName[@attributeName='attributeValue']

211) What are the advantages of selenium webdriver?

Selenium WebDriver is very flexible to use with Java, .Net, Python, Ruby or html languages. QA engineers who have good coding skills can use it very effectively.

212) What are the disadvantages of selenium webdriver over selenium 1.0?

Since selenium web driver requires coding skills, QA engineers should have some knowledge of program development in Java, .Net, or other languages.

213) How to handle multiple windows in selenium webdriver?

We can use web driver's windows handler to identify each window and use switch method to pick the window for test.

214) . How to navigate with browser buttons in selenium webdriver?

We can use web driver's back or forward method to simulate browser's navigation button functionality.

215) Which are the locators used for recognizing the objects in selenium webdriver?

In webdriver, we can use element id, name, css, xpath, link text, partial link text and DOM to locate elements.


216) How to run the tests in internet explorer using selenium webdriver?

When setup a webdriver in the code, we can select InternetExplorerDriver to use ID. If we want to use of the latest and greatest features of the WebDriver "InternetExplorerDriver", we need to download Internet Explorer Server.


217) How to run the tests in firefox using selenium webdriver?

In the setup method, we select FirefoxDriver for the webDriver.


218) How to run the tests in google chrome using selenium webdriver?

Sometimes, webdriver cannot launch chrome directly, so (1) we can use Desired Capabilities of WebDriver, put chrome browser application path in the code ; (2) we need to have chromedriver.exe file in the application path. Alternatively, we can manually start chrome driver service, and then launch the test in chrome.

219) . How to run the tests without a browser or with HTML unit driver in selenium webdriver?

WebDriver driver = new HtmlUnitDriver();

209) How to run Selenium 1.0 tests in webdriver?

We can use WebDriverBackedSelenium to run Selenium 1.0 tests in webdriver.

WebDriver driver = new FirefoxDriver();

Selenium selenium = new WebDriverBackedSelenium(driver, "http://www.yoursite.com");


210) . How to convert selenium 1.0 tests to webdriver tests?

We can use WebDriverBackedSelenium to run Selenium 1.0 tests in webdriver.

WebDriver driver = new FirefoxDriver();

Selenium selenium = new WebDriverBackedSelenium(driver, "http://www.yoursite.com");

211) What is webdriver backed selenium?

WebDriver backed Selenium is API that enables running Selenium 1.0 tests in web driver.

212) When to use web driver backed selenium?

When we have existing tests in Selenium 1.0 (RC), if we want to avoid using Selenium RC, instead we want to use web driver, we need to use web driver backed selenium.

213) . Which version of selenium IDE supports webdriver?

Any version higher than 2.0 supports webdriver.

214) How to invoke an application in webdriver?

We can use Process to invoke application in the code using web driver.

215) Which of Selenium IDE commands not supported in webdriver?

It depends on the format of conversion functionality of Selenium IDE to web driver. sometimes, not all IDE script can be converted to web driver without any problem.

216) Where to download selenium webdriver?

Selenium WebDriver libraries can be download from http://www.seleniumhq.org website.


217) How can we locate an element by only partially matching its attributes value in Xpath?

Using contains() method we can locate an element by partially matching its attribute's value. This is particularly helpful in the scenarios where the attributes have dynamic values with certain constant part.

xPath expression = //*[contains(@name,'user')]

The above statement will match the all the values of name attribute conating the word user in them.

218)Can Selenium test an application on Android browser?
Selenium should be able to handle Android browser. There is experimental Selenium Android Driver for running tests in Android browser.

219) What are the disadvantages of using Selenium as testing tool?
Selenium weak points are tricky setup; dreary errors diagnosis; tests only web applications

220) How many browsers are supported by Selenium Remote Control?
QA Engineer can use Firefox 7, IE 8, Safari 5 and Opera 11.5 browsers to run actuall tests in Selenium RC.

221) How many programming languages can you use in Selenium RC?
Several programming languages are supported by Selenium Remote Control - C# Java Perl PHP Python Ruby

222) How many testing framework can QA Tester use in Selenium RC?
Testing frameworks aren't required, but they can be helpful if QA Tester wants to automate test cases. Selenium RC supports Bromine, JUnit, NUnit, RSpec (Ruby), Test::Unit (Ruby), TestNG (Java), unittest (Python)

223) How to developer Selenium Test Cases?
Using the Selenium IDE, QA Tester can record a test to comprehend the syntax of Selenium IDE commands, or to check the basic syntax for a specific type of user interface. Keep in mind that Selenium IDE recorder is not clever as QA Testers want it to be. Quality assurance team should never consider Selenium IDE as a "record, save, and run it" tool, all the time anticipate reworking a recorded test cases to make them maintainable in the future

224) What programming language is best for writing Selenium tests?
The web applications may be written in Java, Ruby, PHP, Python or any other web framework. There are certain advantages for using the same language for writing test cases as application under test. For example, if the team already have the experience with Java, QA Tester could always get the piece of advice while mastering Selenium test cases in Java. Sometimes it is better to choose simpler programming language that will ultimately deliver better success. In this case QA testers can adopt easier programming languages, for example Ruby, much faster comparing with Java, and can become become experts as soon as possible.

225) Do you know any alternative test automation tools for Selenium?
Selenium appears to be the mainstream open source tool for browser side testing, but there are many alternatives. Canoo Webtest is a great Selenium alternative and it is probably the fastest automation tool. Another Selenium alternative is Watir, but in order to use Watir QA Tester has to learn Ruby. One more alternative to Selenium is Sahi, but is has confusing interface and small developers community

226). How can we locate element using their text in XPath?

Using the text() method -

xPathExpression = //*[text()='username'

227) What is Selenium Grid?
Selenium Grid in the selenium testing suit allows the Selenium RC solution to scale for test suites that must be run in multiple environments. Selenium Grid can be used to run multiple instances of Selenium RC on various operating system and browser configurations.

228) How Selenium Grid works?
Selenium Grid sent the tests to the hub. Then tests are redirected to an available Selenium RC, which launch the browser and run the test. Thus, it allows for running tests in parallel with the entire test suite.


229) What you say about the flexibility of Selenium test suite?
Selenium testing suite is highly flexible. There are multiple ways to add functionality to Selenium framework to customize test automation. As compared to other test automation tools, it is Selenium’s strongest characteristic. Selenium Remote Control support for multiple programming and scripting languages allows the test automation engineer to build any logic they need into their automated testing and to use a preferred programming or scripting language of one’s choice.

Also, the Selenium testing suite is an open source project where code can be modified and enhancements can be submitted for contribution.

230) What test can Selenium do?
Selenium is basically used for the functional testing of web based applications. It can be used for testing in the continuous integration environment. It is also useful for agile testing

231) What is the cost of Selenium test suite?
Selenium test suite a set of open source software tool, it is free of cost.

232) What browsers are supported by Selenium Remote Control?
The test automation expert can use Firefox, IE 7/8, Safari and Opera browsers to run tests in Selenium Remote Control.

233) What programming languages can you use in Selenium RC?
C#, Java, Perl, PHP, Python, Ruby

234) Can Selenium handle windows based pop up?

Selenium is an automation testing tool which supports only web application testing. Therefore, windows pop up cannot be handled using Selenium.

235) What is test automation or automation testing?

Automation testing is used to automate the manual testing. It is a process of automating the manual process to test the application/system under test. It uses separate testing tools which facilitate you to create test scripts which can be executed repeatedly and doesn't need any manual intervention.

236)Can Selenium handle windows based pop up?

Selenium is an automation testing tool which supports only web application testing. Therefore, windows pop up cannot be handled using Selenium.

237) What is test automation or automation testing?

Automation testing is used to automate the manual testing. It is a process of automating the manual process to test the application/system under test. It uses separate testing tools which facilitate you to create test scripts which can be executed repeatedly and doesn't need any manual intervention.

238)What are the advantages of automation testing?

  • It supports execution of repeated test cases.
  • It facilitates parallel execution.
  • It aids in testing a large test matrix.
  • It improves accuracy because there are no chances of human errors.
  • It saves time and money.

239) What is Selenium 1.0?

Selenium 1.0 is popularily known as Selenium Remote Control (Selenium RC). It is a library available in wide variety of languages. The main reason to use Selenium RC was that Selenium IDE was incapable to execute tests in browsers other than Selenium IDE and the limitation of language Selenese used in Selenium IDE.

240) What is an Xpath?

Xpath is used to locate a web element based on its XML path. It can be used to locate HTML elements.

241) What are the different types of Drivers that WebDriver contains?

These are the different drivers available in WebDriver:

  • FirefoxDriver
  • InternetExplorerDriver
  • ChromeDriver
  • SafariDriver
  • OperaDriver
  • AndroidDriver
  • IPhoneDriver
  • HtmlUnitDriver

242) Can you edit tests in Selenium IDE?

Yes, tests in Selenium IDE can be edited. There are two ways to edit tests in Selenium IDE.

  • By Table views
  • Looking into the source code

243)Can you use html id and name while using Selenium IDE?

Yes, You can use html id and name as it is available in Selenium IDE.

Q244) What is the difference between driver.close() and driver.quit command?

close(): WebDriver’s close() method closes the web browser window that the user is currently working on or we can also say the window that is being currently accessed by the WebDriver. The command neither requires any parameter nor does is return any value.

quit(): Unlike close() method, quit() method closes down all the windows that the program has opened. Same as close() method, the command neither requires any parameter nor does is return any value.

Q 245) Can Selenium handle windows based pop up?

Selenium is an automation testing tool which supports only web application testing. Therefore, windows pop up cannot be handled using Selenium.

Q 246) How can we handle web based pop up?

WebDriver offers the users with a very efficient way to handle these pop ups using Alert interface. There are the four methods that we would be using along with the Alert interface.

  • void dismiss() – The accept() method clicks on the “Cancel” button as soon as the pop up window appears.
  • void accept() – The accept() method clicks on the “Ok” button as soon as the pop up window appears.
  • String getText() – The getText() method returns the text displayed on the alert box.
  • void sendKeys(String stringToSend) – The sendKeys() method enters the specified string pattern into the alert box.

Syntax:
// accepting javascript alert
Alert alert = driver.switchTo().alert();
alert.accept();

Q 247) How can we handle windows based pop up?

Selenium is an automation testing tool which supports only web application testing, that means, it doesn’t support testing of windows based applications. However Selenium alone can’t help the situation but along with some third party intervention, this problem can be overcome. There are several third party tools available for handling window based pop ups along with the selenium like AutoIT, Robot class etc.

Q 248 ) How to assert title of the web page?

//verify the title of the web page
assertTrue(“The title of the window is incorrect.”,driver.getTitle().equals(“Title of the page”));

Q249) How to mouse hover on a web element using WebDriver?

WebDriver offers a wide range of interaction utilities that the user can exploit to automate mouse and keyboard events. Action Interface is one such utility which simulates the single user interactions.

Thus, In the following scenario, we have used Action Interface to mouse hover on a drop down which then opens a list of options.

Sample Code:

1

// Instantiating Action Interface

2

Actions actions=new Actions(driver);

3

// howering on the dropdown

4

actions.moveToElement(driver.findElement(By.id("id of the dropdown"))).perform();

5

// Clicking on one of the items in the list options

6

WebElement subLinkOption=driver.findElement(By.id("id of the sub link"));

7

subLinkOption.click();

Q250) How to retrieve css properties of an element?

The values of the css properties can be retrieved using a get() method:

Syntax:
driver.findElement(By.id(“id“)).getCssValue(“name of css attribute”);
driver.findElement(By.id(“id“)).getCssValue(“font-size”);

251)What are the advantages and disadvantages of using Selenium as testing tool?
Advantages: Free, Simple and powerful DOM (document object model) level testing, can be used for continuous integration; great fit with Agile projects.

Disadvantages: Tricky setup; dreary errors diagnosis; can not test client server applications.

252) What is difference between QTP and Selenium?
Only web applications can be testing using Selenium testing suite. However, QTP can be used for testing client server applications. Selenium supports following web browsers: Internet Explorer,

Firefox, Safari, Opera or Konqueror on Windows, Mac OS X and Linux. However, QTP is limited to Internet Explorer on Windows.

QTP uses scripting language implemented on top of VB Script. However, Selenium test suite has the flexibility to use many languages like Java, .Net, Perl, PHP, Python, and Ruby.

253) What is difference between Borland Silk test and Selenium?
Selenium is completely free test automation tool, while Silk Test is not. Only web applications can be testing using Selenium testing suite. However, Silk Test can be used for testing client server applications. Selenium supports following web browsers: Internet Explorer, Firefox, Safari, Opera or Konqueror on Windows, Mac OS X and Linux. However, Silk Test is limited to Internet Explorer and Firefox.

Silk Test uses 4Test scripting language. However, Selenium test suite has the flexibility to use many languages like Java, .Net, Perl, PHP, Python, and Ruby.

254) What is the difference between an assert and a verify with Selenium commands?
Effectively an “assert” will fail the test and abort the current test case, whereas a “verify” will fail the test and continue to run the test case.

255. If a Selenium function requires a script argument, what would that argument look like in general terms?
StoreEval(script, variable) and storeExpression(expression, variableName)

256) If a Selenium function requires a pattern argument, what five prefixes might that argument have?
glob, regexp, exact, regexpi

257) Explain what is Datadriven framework and Keyword driven?

Datadriven framework: In this framework, the test data is separated and kept outside the Test Scripts, while test case logic resides in Test Scripts. Test data is read from the external files ( Excel Files) and are loaded into the variables inside the Test Script. Variables are used for both for input values and for verification values.

258) Which attribute you should consider throughout the script in frame for “if no frame Id as well as no frame name”?

You can use…..driver.findElements(By.xpath(“//iframe”))….

This will return list of frames.
You will ned to switch to each and every frame and search for locator which we want.
Then break the loop

259) Mention what is the difference between Implicit wait and Explicit wait?

Implicit Wait: Sets a timeout for all successive Web Element searches. For the specified amount of time it will try looking for element again and again before throwing a NoSuchElementException. It waits for elements to show up.

Explicit Wait : It is a one-timer, used for a particular search.

260) What tests can selenium do?

Selenium could do functional, regression, and load of web based applications.

261) What is the selenium’s recording language?

Selenium’s recording language is “HTML”.

262) What is WebDriver?

WebDriver is a tool for writing automated tests of websites. It aims to mimic the behaviour of a real user, and as such interacts with the HTML of the application.

263) Can Selenium test a application on iPhone’s Mobile Safari browser?

Selenium can handle Mobile Safari browser. There is experimental Selenium IPhone Driver for running tests on Mobile with Safari on the iPhone and iPad and iPod Touch.

265)What is the selenium’s recording language?

Selenium’s recording language is “HTML”.

266) What are the steps to run automation using selenium?

The very basic steps are:

1. Record the test steps using selenium-IDE.

2. Modify the script according to the testing needs. Add validation points, Java Scripts, Time-out etc.

3. Run the test.

View the result after test run complete analyze.

267) What are the capabilities of Selenium IDE?

Selenium IDE (Integrated Development Environment) works similar to commercial tools like QTP, Silk Test and Test Partner etc.

The below points describes well about Selenium IDE.

1. Selenium IDE is a Firefox add-on.

2. Selenium IDE can support recording the clicks, typing, and other actions to make a test cases.

3. Using Selenium IDE, a tester can play back the test cases in the Firefox browser.

4. Selenium IDE supports exporting the test cases and suites to Selenium RC.

5. Debugging of the test cases with step-by-step can be done.

6. Breakpoint insertion is possible.

7. Page abstraction functionality is supported by Selenium IDE.

8. Selenium IDE can supports an extensibility capability allowing the use of add-ons or user extensions that expand the functionality of Selenium IDE.

268) What is WebDriver?

WebDriver is a tool for writing automated tests of websites. It aims to mimic the behaviour of a real user, and as such interacts with the HTML of the application.

269) So, is it like Selenium? Or Sahi?

The aim is the same (to allow you to test your webapp), but the implementation is different. Rather than running as a Javascript application within the browser (with the limitations this brings, such as the “same origin” problem), WebDriver controls the browser itself. This means that it can take advantage of any facilities offered by the native platform.

270) How do I migrate from using the original Selenium APIs to the new WebDriver APIs?

Answer:A common question when adopting Selenium 2 is what’s the correct thing to do when adding new tests to an existing set of tests? Users who are new to the framework can begin by using the new WebDriver APIs for writing their tests. But what of users who already have suites of existing tests? This guide is designed to demonstrate how to migrate your existing tests to the new APIs, allowing all new tests to be written using the new features offered by WebDriver.

271) :How to capture page title using Selenium 2.0?

String title = driver.getTitle()

272) How to store page source using Selenium 2.0?

String pagesource = driver.getPageSource()

273) How to store current url using selenium 2.0?

String currentURL = driver.getCurrentUrl()

274) How to assert text assert text of webpage using selenium 2.0?

WebElement el = driver.findElement(By.id("ElementID"));

//get test from element and stored in text variable

String text = el.getText();

//assert text from expected

Assert.assertEquals("Element Text", text);

275) How to get element attribute using Selenium 2.0?

WebElement el = driver.findElement(By.id("ElementID"));

//get test from element and stored in text variable

String attributeValue = el. getAttribute("AttributeName") ;

276) How to double click on element using selenium 2.0?

WebElement el = driver.findElement(By.id("ElementID"));

Actions builder = new Actions(driver);

builder.doubleClick(el).build().perform();

277) : How to perform drag and drop in selenium 2.0?

WebElement source = driver.findElement(By.id("Source ElementID"));

WebElement destination = driver.findElement(By.id("Taget ElementID"));

Actions builder = new Actions(driver);

builder.dragAndDrop(source, destination ).perform();

278) How to maximize window using selenium 2.0?

driver.manage().window().maximize();

279) How to put text in Facebook search box using
selenium web driver.

  • driver.findElement(By.xpath("//div[contains(@class, '_586i')]")).sendKeys("abc");

280)Difference between flex and flash application.

In flash there is no code just based on creativity(design) we will complete the
work(time consuming process) whereas flex contain some small functions
which is integrated with mxml,PHP..(no tool is there to develop

flex we want to use the properties of css and style sheet)

281)What is Error Collector in TestNG? What is its use?

This class allows the collection of errors during the process of retrieving the
test data for the test method parameters

282) How can we get the font size, font color, font type used for a particular text on a web page using Selenium web driver?

driver.findelement(By.Xpath("Xpath ").getcssvalue("font-size);

driver.findelement(By.Xpath("Xpath ").getcssvalue("font-colour);

driver.findelement(By.Xpath("Xpath ").getcssvalue("font-type);

driver.findelement(By.Xpath("Xpath ").getcssvalue("background-colour);

283))How to prepare Customized html Report using TestNG in hybrid framework.

Below are the 3 ways:

  • Junit: with the help of ANT.
  • TestNG: using inbuilt default.html to get the HTML report. Also XST reports from ANT,

Selenium, TestNG combination.

  • Using our own customized reports using XSL jar for converting XML content to HTML.

284) How can I read test data from excels?

Test data can efficiently be read from excel using JXL or POI API. See detailed tutorial here.

285) What is the difference between POI and jxl jar?

#

JXL jar

POI jar

1

JXL supports “.xls” format i.e. binary based format. JXL doesn’t support Excel 2007 and “.xlsx” format i.e. XML based format

POI jar supports all of these formats

2

JXL API was last updated in the year 2009

POI is regularly updated and released

3

The JXL documentation is not as comprehensive as that of POI

POI has a well prepared and highly comprehensive documentation

4

JXL API doesn’t support rich text formatting

POI API supports rich text formatting

5

JXL API is faster than POI API

POI API is slower than JXL API

286) What is the difference between Selenium and QTP?

Feature

Selenium

Quick Test Professional (QTP)

Browser Compatibility

Selenium supports almost all the popular browsers like Firefox, Chrome, Safari, Internet Explorer, Opera etc

QTP supports Internet Explorer, Firefox and Chrome. QTP only supports Windows Operating System

Distribution

Selenium is distributed as an open source tool and is freely available

QTP is distributed as a licensed tool and is commercialized

Application under Test

Selenium supports testing of only web based applications

QTP supports testing of both the web based application and windows based application

Object Repository

Object Repository needs to be created as a separate entity

QTP automatically creates and maintains Object Repository

Language Support

Selenium supports multiple programming languages like Java, C#, Ruby, Python, Perl etc

QTP supports only VB Script

Vendor Support

As Selenium is a free tool, user would not get the vendor’s support in troubleshooting issues

Users can easily get the vendor’s support in case of any issue

287) Can WebDriver test Mobile applications?

WebDriver cannot test Mobile applications. WebDriver is a web based testing tool, therefore applications on the mobile browsers can be tested.

288) Can captcha be automated?

No, captcha and bar code reader cannot be automated.

289) What is Object Repository? How can we create Object Repository in Selenium?

Object Repository is a term used to refer to the collection of web elements belonging to Application Under Test (AUT) along with their locator values. Thus, whenever the element is required within the script, the locator value can be populated from the Object Repository. Object Repository is used to store locators in a centralized location instead of hard coding them within the scripts.

Q 290) How to select value in a dropdown?

Value in the drop down can be selected using WebDriver’s Select class.

Syntax:

selectByValue:
Select selectByValue = newSelect(driver.findElement(By.id(“SelectID_One”)));
selectByValue.selectByValue(“greenvalue”);

selectByVisibleText:
Select selectByVisibleText = new Select (driver.findElement(By.id(“SelectID_Two”)));
selectByVisibleText.selectByVisibleText(“Lime”);

selectByIndex:
Select selectByIndex = newSelect(driver.findElement(By.id(“SelectID_Three”)));
selectByIndex.selectByIndex(2);

Q 291) What are the different types of navigation commands?

Following are the navigation commands:
navigate().back() – The above command requires no parameters and takes back the user to the previous webpage in the web browser’s history.

Sample code:
driver.navigate().back();

navigate().forward() – This command lets the user to navigate to the next web page with reference to the browser’s history.

Sample code:
driver.navigate().forward();

navigate().refresh() – This command lets the user to refresh the current web page there by reloading all the web elements.

Sample code:
driver.navigate().refresh();

navigate().to() – This command lets the user to launch a new web browser window and navigate to the specified URL.

Sample code:
driver.navigate().to(“https://google.com”);

Q 292) How to click on a hyper link using linkText?

driver.findElement(By.linkText(“Google”)).click();

The command finds the element using link text and then click on that element and thus the user would be re-directed to the corresponding page.

The above mentioned link can also be accessed by using the following command.

293)When do we use findElement() and findElements()?

findElement(): findElement() is used to find the first element in the current web page matching to the specified locator value. Take a note that only first matching element would be fetched.

Syntax:

WebElement element =driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));
findElements(): findElements() is used to find all the elements in the current web page matching to the specified locator value. Take a note that all the matching elements would be fetched and stored in the list of WebElements.

Syntax:
List <WebElement> elementList =driver.findElements(By.xpath(“//div[@id=’example’]//ul//li”));

Q 294) How to find more than one web element in the list?

At times, we may come across elements of same type like multiple hyperlinks, images etc arranged in an ordered or unordered list. Thus, it makes absolute sense to deal with such elements by a single piece of code and this can be done using WebElement List.

Sample Code

1

// Storing the list

2

List <WebElement> elementList = driver.findElements(By.xpath("//div[@id='example']//ul//li"));

3

// Fetching the size of the list

4

int listSize = elementList.size();

5

for (int i=0; i<listSize; i++)

6

{

7

// Clicking on each service provider link

8

serviceProviderLinks.get(i).click();

9

// Navigating back to the previous page that stores link to service providers

10

driver.navigate().back();

11

}

295) What is the use of context menu in Selenium IDE?
It allows the user to pick from a list of assertions and verifications for the selected location.

296) Can tests recorded using Selenium IDE be run in other browsers?
Yes. Although Selenium IDE is a Firefox add on, however, tests created in it can also be run in other browsers by using Selenium RC (Selenium Remote Control) and specifying the name of the test suite in command line.

297) . What are the advantage and features of Selenium IDE?
a. Intelligent field selection will use IDs, names, or XPath as needed
b. It is a record & playback tool and the script format can be written in various languages including C#, Java, PERL, Python, PHP, HTML
c. Auto complete for all common Selenium commands
d. Debug and set breakpoints
e. Option to automatically assert the title of every page
f. Support for Selenium user-extensions.js file

298) What are the disadvantage of Selenium IDE tool?
a. Selenium IDE tool can only be used in Mozilla Firefox browser.
b. It is not playing multiple windows when we record it.

299) . What is Selenium RC (Remote Control)?
Selenium RC allows the test automation expert to use a programming language for maximum flexibility and extensibility in developing test logic. For example, if the application under test returns a result set and the automated test program needs to run tests on each element in the result set, the iteration / loop support of programming language’s can be used to iterate through the result set, calling Selenium commands to run tests on each item. Selenium RC provides an API and library for each of its supported languages. This ability to use Selenium RC with a high level programming language to develop test cases also allows the automated testing to be integrated with the project’s automated build environment.

300) Mention what is the use of X-path?

X-Path is used to find the WebElement in web pages. It is also useful in identifying the dynamic elements.


Selenium Interview Questions 1

Selenium Interview Questions 2

Selenium Interview Questions 3

Selenium Interview Questions 4