0

I have a HTML as follows:

<input type="checkbox" name="jform[groups][]" value="2" id="1group_2" checked="checked" rel="1group_1">

I want to get the attribute "checked" from this using selenium webdriver. How do I do that?

Thanks for your help in advance.

Farhaan Patel
  • 59
  • 1
  • 5

1 Answers1

0

As per the HTML you have shared to retrieve the value checked from the attribute checked you can use:

  • css_selector:

    driver.find_element_by_css_selector("input[id*='group_'][name^='jform'][type='checkbox']").get_attribute("checked")
    
  • xpath:

    driver.find_element_by_xpath("//input[contains(@id,'group_') and starts-with(@name,'jform')][@type='checkbox']").get_attribute("checked")
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352