Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. Find an element by partial attribute value.
  2.  
  3. Sample html code : <input id="react-select-2-input">
  4.  
  5. Comment : For example the above input element has attribute id contains numeric value "2" the numeric value is a dynamic value and changes when the page is refreshed or loaded.
  6. In this case we need to find the id by partial value "react-select-" ignoring the rest of the value.
  7.  
  8. driver.FindElement(By.CssSelector("[id*=react-select]")).SendKeys("Attraction");
  9.  
  10. Comment: Other uses
  11.  
  12. (By.CssSelector("[id*=react-select]")) -- use * to find the id value containing "react-select"
  13.  
  14. (By.CssSelector("[id#=react]")) -- use # to find the id value begining with "react"
  15.  
  16. (By.CssSelector("[id$=input]")) -- use # to find the id value ending with "input"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement