mardi 8 novembre 2016

How to Test if CheckBox is Checked in Python Using Selenium

Is there a way to determine whether a box is checked using Selenium in Python?

Here's the code when the box is not checked:

<input id="AllDocumentListView_selectAllDocuments" type="checkbox" onclick="com.reuters.rts.event(this, 'updateCheckBoxState', 'researchTableManagerId', 'AllDocumentListView', 'node', null, 'selected', this.checked);"> == $0

Here's the code when the box is checked:

<input id="AllDocumentListView_selectAllDocuments" type="checkbox" onclick="com.reuters.rts.event(this, 'updateCheckBoxState', 'researchTableManagerId', 'AllDocumentListView', 'node', null, 'selected', this.checked);"> == $0 ::after </input>

If I use the following code to get the outerHTML:

checkbox = ff.find_element_by_id("AllDocumentListView_selectAllDocuments")
checkbox.get_attribute('outerHTML')

then the output is:

<input id="AllDocumentListView_selectAllDocuments" type="checkbox" onclick="com.reuters.rts.event(this, 'updateCheckBoxState', 'researchTableManagerId', 'AllDocumentListView', 'node', null, 'selected', this.checked);">

And this is regardless of whether the box is checked or not. Is there a way to determine if the box is checked?




Aucun commentaire:

Enregistrer un commentaire