You are on page 1of 3

1.

Find XPath for ALL "radio-buttons"


//input[@name="radio"]

2. Find XPath only for second "radio-button"


//input[@id="radio2"]

3. Write XPath for text "HTML5 inputs"


//legend[contains(.,'HTML5 inputs')]

4. Find XPath for "type-password" field


//input[@id='input__password']

5. Find XPath for id='ir'


//input[@id='ir']

6. Find XPath for button contains text "button type=submit"


//button[@type='submit']

7. Find XPath for name='radio'


//input[@name='radio']

8. Find XPath for id='radio3'


//input[@id='radio3']

9. Find XPath for link http://twitter.com/cbracco


//a[@href='http://twitter.com/cbracco']

10. Find XPath for "input" tag with attribute id='input__text'


//input[@id='input__text']

11. Find XPath for "any" attribute value with id='input__text'


//*[@id='input__text']

12. Find XPath by text value "Form elements" (all xpath)


//*[contains(text(),'Form elements')]
//*[text()="Form elements"]

13. Find XPath by text value "Form elements" and href='#forms' (unique
xpath)
//a[text()="Form elements" and @href="#forms"]

14. Find XPath by input type (email)


//input[@type='email']

15. Find XPath by partial value "ext Input"


//*[contains(text(), 'ext Input')]

16. Find XPath by partial ID value "put__text"


//*[contains(@id, 'put__text')]

17. Find XPath by "starts-with" for "id" tag with value


"input__search"
//*[starts-with(@id, 'input__search')]

18. Find XPath by values id='input__text' and by "type" attribute with


value "text""
//input[@id='input__text' and @type='text']

19. Find XPath by "starts-with" for "id" tag with value


"input__search", then go to level UP to the parent
//*[starts-with(@id, 'input__search')]/..

-20. Find XPath by “id” within “div” element contains text 'Definition
list'
//*[contains(text(), 'Definition list')]
//h3[contains(text(),'Definition list')]
//div[contains(text(), 'Definition list')]/@id not works

21. Find XPath by “id=select", then go one level inside and select
option with value “Option One"
//select[@id='select']/optgroup/option[text()='Option One']

22. Find XPath by “id=select", then go one level inside and select
option contains text 'Option Two'
//*[@id='select']//option[contains(text(),'Option Two')]

23. Find XPath by “id=textarea”, then go 1 level UP, then find inside
element item by “partial text” = "xtarea"
//*[@id='textarea']/..//*[contains(text(),'xtarea')]

24. Find XPath by “text=Valid”, then go 2 levels UP, then find inside
element item by “id=input__password"
//*[text()='Valid']/..//..//*[@id='input__password']

25. Find XPath by 2 attributes: "id=input__text2" and "type=number"


//*[@id='input__text2' and @type='number']

26. Find XPath by placeholder="Enter Search Term"


//*[@placeholder='Enter Search Term']

27. Find XPath for id='idm' as an child element for "HTML5 inputs"
form
//*[contains(text(),'HTML5 inputs')]/..//*[@id='idm']

28. Find XPath by input type (tel)


//*[@type='tel']
//input[@type='tel']

29. Find XPath by partial value 'deo2-"Na Mars"'


//*[contains(text(),'deo2-"Na Mars"')]
30. Find XPath by id="select"
//*[@id='select']

31. Find XPath by src=http://placekitten.com/480/480


//*[@src='http://placekitten.com/480/480']

32. Find XPath by placeholder="Enter your message here"


//*[@placeholder='Enter your message here']

33. Find XPath by value="#000000"


//*[@value='#000000']

34. Find XPath by value="<input type=submit>"


//*[@value='<input type=submit>']

35. Find XPath by href = https://github.com/cbracco/html5-test-page


//*[@href='https://github.com/cbracco/html5-test-page']

36. Find XPath by id="idt"


//*[@id='idt']

37. Find XPath by type="checkbox"


//*[@type='checkbox']

38. Find XPath by id="input__text3"


//*[@id='input__text3']

39. Find XPath by type="text" for all text field elements


//*[@type='text']
//input[@type='text']

40. Find XPath by alt="Image alt text" for all 3 images


//*[@alt='Image alt text']

You might also like