Selenium find button element
You can use ActionChains
to move to the element before clicking on it
from selenium.webdriver.common.action_chains import ActionChains
element = br.find_element_by_xpath("//input[@id='place_order']")
ActionChains(br).move_to_element(element).perform() # I assume br is your webdriver
element.click()
If you don't want to use xpath
you can use find_element_by_id('place_order')
You can find here more ways to locate elements
Admin
Updated on June 04, 2022Comments
-
Admin over 1 year
I want to find a button element on a website with
selenium
onpython 3
. I try some different method but all failed . I useXpath
to find my element but i don't know if it's the better method :This is the
HTML
code :<div id="review-buttons-container"> <div class="columns"> <div class="please-wait" id="review-please-wait" style="display:none;"> <span>PROCESSING...</span> </div> <input id="place_order" type="button" value="Complete Order" class="button end"/> </div> </div>
This what i already try on python :
br.find_element_by_xpath("//input[@id='place_order']").click()
return :
selenium.common.exceptions.WebDriverException: Message: unknown error: Element is not clickable at point (606, 678). Other element would receive the click :
- ...
//div[@id='review-buttons-container']/div/input
return :
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@id='review-buttons-container']/div/input"}
br.find_element_by_xpath("//form[2]/div[8]/div/input").click()
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//form[2]/div[8]/div/input"}
Any idea ? thanks