Download presentation
Presentation is loading. Please wait.
Published byJeffry Cook Modified over 8 years ago
1
Test Automation For Web-Based Applications Portnov Computer School Presenter: Ellie Skobel
2
2 Day 2 Locating Elements
3
Required for most Selenium commands assertText storeSelectOptions click type and many others Identifies an element in the content of the web application Consists of the location strategy followed by the location ◦ locatorType=location
4
Locators starting with “document” will use the DOM locator strategy dom = document.forms[0].username document.forms[0].elements['username‘] Locators starting with “//” will use the XPath locator strategy //input[@name='continue'][@type='button'] xpath=/html/body/form/input[4] Locators that don’t specify a valid locator type will default to using the identifier locator. identifier=loginForm username
5
CSS selectors can be used by Selenium as another locating strategy To locate css class append the class name to the parent tag name using a period (.) To locate css id append the id name to the parent tag name using a pound sign (#) To locate by property, include the property name and value in square brackets next to the parent tag name. css=input.required passfield [type=“password"] css=input.required passfield [type=“password"] css=input [name="username"] css=input [name="username"] css=form#loginForm
6
CSS: http://www.w3.org/TR/css3-selectors/ Xpath http://www.w3schools.com/Xpath/ http://www.w3.org/TR/xpath Also PDF and PDFPDF
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.