0

I need to check a checkbox called standards,

please see screenshot.

enter image description here

I was able to expand the information type dropdown via:

By.xpath("//div[contains(@class, 'expand') and h3[contains(text(), 'Information Type')]]") 
Saurabh Gaur
  • 23,507
  • 10
  • 54
  • 73
Tony
  • 25
  • 2
  • 6
  • I was able to expand the information type dropdown via: By.xpath("//div[contains(@class, 'expand') and h3[contains(text(), 'Information Type')]]") – Tony Sep 14 '16 at 03:58

1 Answers1

1

After expand Information Type element you should wait until Standards check box element getting visible and clickable using WebDriverWait as below :-

new WebDriverWait(driver,10).until(ExpectedConditions.elementToBeClickable(By.xpath(".//li[normalize-space(.)='Standards']/input"))).click();

You can also use this xpath as well :

.//li[contains(.,'Standards')]/input
Saurabh Gaur
  • 23,507
  • 10
  • 54
  • 73
  • Hi, can you explain a bit more about the xpath expression: .//li[normalize-space(.)='Standards']/input? I am a bit lost. Why do you need /input at the end? Thanks – Tony Sep 15 '16 at 21:57
  • Also why do you need .// instead of // at the front? – Tony Sep 15 '16 at 22:17
  • `//li[normalize-space(.)='Standards']` this just returns `li` element with `input` element child so again `/input` gives me desire element which contain `Standards` text. – Saurabh Gaur Sep 15 '16 at 22:25
  • You can use both `.//` and `//` here, `.` just determine in which context you want to search for the element. But here `.` doesn't play any role here because you're searching element on whole page context, it just for best practice if some time if you to get desire element some thing like as `driver.findElement("//li[normalize-space(.)='Standards']").findElement(".//input"));` here using `.` would search`input` element only first found `li` element context instead of whole page context. Thanks – Saurabh Gaur Sep 15 '16 at 22:31
  • @Tony For more details [have a look here](http://stackoverflow.com/questions/35606708/what-is-the-difference-between-and-in-xpath) – Saurabh Gaur Sep 15 '16 at 22:35