0 votes
1 view
in DevOps and Agile by (19.8k points)

It would be nice if someone knows how to select the checkbox using Selenium with Python.

from selenium import webdriver

from selenium.webdriver.common.keys import Keys

browser = webdriver.Firefox()

url = 'any url'

browser.get(url)

browser.find_element_by_id("15 Minute Stream Flow Data: USGS (FIFE)").click()

I want to select the checkbox corresponding to 15 Minute Stream Flow Data: USGS (FIFE.

I tried as id, name, link_text but could not detect what should be used?

1 Answer

0 votes
by (63.4k points)

The checkbox HTML is:

<input id="C179003030-ORNL_DAAC-box" name="catalog_item_ids[]" type="checkbox" value="C179003030-ORNL_DAAC">

so you can use

browser.find_element_by_id("C179003030-ORNL_DAAC-box").click()

One way you can find elements' attributes is using the Google Chrome Developer Tools:

Inspect element

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...