I am working on a selenium script in Python, where I am on this stage trying to locate a submit button.
<div class="submit-buttons">
<button class="submit" type="submit">Filter</button>
</div>
I've tried and this has not worked.
So I am out of solutions:
browser.find_element_by_partial_link_text('Filter').click()
browser.find_element_by_link_text('Filter').click()
browser.find_element_by_class_name('submit').click()
Try xpath solution:
driver.find_element_by_xpath('//div[@class="submit-buttons"]/button[@class="submit"]')
If it is still not identifying, the element might be inside a frame, and you have to switch to that frame before finding the element.
By link text or by partial link text locators are going to work with links only - a
elements . Here you have a button. If you want to use the button text, use the following "by xpath" locator:
//button[. = "Filter"]
这段代码应该有效:
driver.find_element_by_xpath('//button[text()='Filter']')
driver.findElement(By.cssSelector("button[type=\"submit\"]")).click();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.