Python Forum
How to trigger click event on Button without ID/Name
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to trigger click event on Button without ID/Name
#5
Be aware that find_elements_by_css_selector and find_elements_by_xpath return a list so use [0].
button = browser.find_elements_by_css_selector('.btn')
button[0].click()
So CSS .btn and Xpath //button[@type='button'] are direct reference to button,of course if many buttons then need a more specific path.

For Path you have found.
time.sleep(3) # Add some time to give site time to load
button = browser.find_elements_by_xpath("/html/body/div[1]/div/div/div[2]/div[2]/div/div/div/div/div[2]/div[2]/div/div[2]")
button[0].click()
Reply


Messages In This Thread
RE: How to trigger click event on Button without ID/Name - by snippsat - Jan-27-2019, 03:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  cant click button by script at page michael1834 1 1,115 Dec-08-2023, 04:44 PM
Last Post: SpongeB0B
  Click on a button on web page using Selenium Pavel_47 7 4,774 Jan-05-2023, 04:20 AM
Last Post: ellapurnellrt
  button click error rafarangel 2 3,163 Feb-11-2021, 08:19 PM
Last Post: buran
  Log In Button Won't Click - Python Selenium Webdriver samlee916 2 3,872 Jun-07-2020, 04:42 PM
Last Post: samlee916
  How to click facebook message button JanelleGuthrie 2 2,443 May-14-2020, 06:02 PM
Last Post: Larz60+
  Clicking on element not triggering event in Selenium Python (Event Key is not in data dkaeloredo 2 4,309 Feb-16-2020, 05:50 AM
Last Post: dkaeloredo
  Contact form button click action Man_from_India 1 2,832 Feb-01-2020, 06:21 PM
Last Post: snippsat
  HOWTO? Login DSL Modem with Python Requests: need Click "Apply" Button Webtest 4 8,546 Aug-20-2019, 04:03 PM
Last Post: johnmina
  Selenium click on popup button??? GuJu 7 8,021 Jul-20-2019, 09:21 AM
Last Post: Nizam
  how to click javascript button hcyeap 3 4,976 Aug-16-2018, 01:26 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020