'How do I click the label element with Selenium?
I would like to click the label but my code does not work. How should I correct my code to work?
My code
elem = driver.findElement(By.xpath(//*[@id="071b5fe1-9d03-11ec-996d-47b2e9c07771_label"]).click()
HTML of webpage I want to crawl
<label for="071b11c0-9d03-11ec-996d-47b2e9c07771" class="form-selector-label" id="071b11c0-9d03-11ec-996d-47b2e9c07771_label"><span class="row"><span class="form-selector-left-col column large-6"><span class="form-selector-title"><span class="as-chicklets-wrap" role="text">
<span class="as-dimension-chicklets" aria-hidden="true">iPhone 13 Pro</span>
<span class="as-tabnav-text">iPhone 13 Pro</span>
</span>
<span>6.1-inch display¹</span></span></span><span class="form-selector-right-col column large-6"><span> <span class="price-point price-point-fullPrice">From <span class="nowrap">HK$8,499</span></span></span></span></span></label>
Solution 1:[1]
This can help you. link
elem = driver.find_element_by_class_name('form-selector-label').click()
elem = driver.findElement(By.id("071b11c0-9d03-11ec-996d-47b2e9c07771_label")).click();
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Sadra |
