jeudi 8 août 2019

(Python/Selenium) How do I check if a checkbox is "checked"?

So when I inspect element and check the dom properties of the checkbox, the property "checked" is either true or false, but when I try to get this value, it always returns true.

Html:

<div role="textbox" id="id-KbdACAbb1Pn-cell-3-2" class="spreadsheet-cell react-cell document-content short-cell" aria-labelledby="id-KbdACAbb1Pn-cell-3-2-label" data-spreadsheet-cell-type="0" data-spreadsheet-cell-row="3" data-spreadsheet-cell-col="2" style="width: 72px; top: 77px; left: 115.969px; height: 22px; background-color: rgb(225, 225, 225); border-color: rgb(194, 199, 201); color: rgb(51, 51, 51); text-align: center; justify-content: center; align-items: center;">
  <div>
    <div id="id-KbdACAbb1Pn-cell-3-2-label" aria-hidden="true" class="a11y-hidden-description-text">C4</div>
  </div>
  <input type="checkbox" class="spreadsheet-checkbox" value="on">
</div>

My code:

temp = b.browser.find_element_by_id("id-KbdACAbb1Pn-cell-3-2")
temp = b.browser.find_element_by_tag_name("input")
print(str(temp.is_enabled()))

Page: Image of browser and dom element

I've tried: temp.is_enabled(), temp.is_selected() and temp.get_attribute("checked")

Other info: I'm trying to automate a quip spreadsheet and I'm using windows and Firefox.




Aucun commentaire:

Enregistrer un commentaire