Sceneggiatura: Mark Andrus, James L. Qui siamo a New York: se ce la fai qui, ce la puoi fare. Stai facendo una cosa molto bella occupandoti di Simon.
Locator is a command that tells Selenium IDE which GUI elements ( say Text Box, Buttons, Check Boxes etc) its needs to operate on. Identification of correct GUI elements is a prerequisite to creating an automation script. But accurate identification of GUI elements is more difficult than it sounds. Sometimes, you end up working with incorrect GUI elements or no elements at all! Hence, Selenium provides a number of Locators to precisely locate a GUI element The different types of Locators in Selenium IDE. • • • • • • • • • • • • • • • There are commands that do not need a locator (such as the 'open' command). However, most of them do need Locators.
The choice of locator depends largely on your Application Under Test. In this tutorial, we will toggle between Facebook, new tours.demoaut on the basis of locators that these applications support. Likewise in yourproject, you will select any of the above-listed locators based on your application support. Locating by ID This is the most common way of locating elements since ID's are supposed to be unique for each element. Target Format: id= id of the element For this example, we will use Facebook as our test app because Mercury Tours do not use ID attributes.
Since this tutorial was created, Facebook has changed their Login Page Design. Marionette of the labyrinth full game. Use this demo page for testing.
Inspect the 'Email or Phone' text box using Firebug and take note of its ID. In this case, the ID is 'email.'
Launch Selenium IDE and enter 'id=email' in the Target box. Click the Find button and notice that the 'Email or Phone' text box becomes highlighted with yellow and bordered with green, meaning, Selenium IDE was able to locate that element correctly. Locating by Name Locating elements by name are very similar to locating by ID, except that we use the 'name=' prefix instead. Target Format: name= name of the element In the following demonstration, we will now use Mercury Tours because all significant elements have names. Navigate to and use Firebug to inspect the 'User Name' text box.
Take note of its name attribute. Here, we see that the element's name is 'userName'. In Selenium IDE, enter 'name=userName' in the Target box and click the Find button. Selenium IDE should be able to locate the User Name text box by highlighting it. Locating by Name using Filters Filters can be used when multiple elements have the same name.
Filters are additional attributes used to distinguish elements with the same name. Target Format: name= name_of_the_element filter= value_of_filter Let's see an example - Step 1. Log on to Mercury Tours using 'tutorial' as the username and password. It should take you to the Flight Finder page shown below. Using Firebug, notice that the Round Trip and One Way radio buttons have the same name 'tripType.' However, they have different VALUE attributes so we can use each of them as our filter.
• We are going to access the One Way radio button first. Click the first line on the Editor. • In the Command box of Selenium IDE, enter the command 'click'.
• In the Target box, enter 'name=tripType value=oneway'. The 'value=oneway' portion is our filter. Click the Find button and notice that Selenium IDE is able to highlight the One Way radio button with green - meaning that we are able to access the element successfully using its VALUE attribute. Press the 'X' key in your keyboard to execute this click command.
Notice that the One Way radio button became selected. You can do the exact same thing with the Round Trip radio button, this time, using 'name=tripType value=roundtrip' as your target. Locating by Link Text This type of locator applies only to hyperlink texts. We access the link by prefixing our target with 'link=' and then followed by the hyperlink text. Target Format: link= link_text In this example, we shall access the 'REGISTER' link found on the Mercury Tours homepage. • First, make sure that you are logged off from Mercury Tours.
- Author: admin
- Category: Category