Python Forum
How to click the button automatically using python
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to click the button automatically using python
#18
hi All,
I tried my code for google page also. I trying to access google search tab. Everyone can ealsiy find HTML page of google page. I am sharing my code and it is returning empty string
from selenium import webdriver
from selenium.webdriver.common.keys import Keys

#Getting local session of Chrome
driver=webdriver.Chrome()

#put here the adress of your page
driver.get("https://www.google.co.in")
#put here the content you have put in Notepad, ie the XPath

'''elem=driver.find_elements_by_xpath('//*[@id]')############### to find id,name replace id,name with class 
for ii in elem:
	print(ii.get_attribute('id'))'''
	
elem=driver.find_elements_by_name("btnk")############### this is one of class 
print(elem)

'''elem2=driver.find_element_by_class_name('row')
#print(elem2)
elementList = elem2.find_elements_by_tag_name("div")	
print(elementList)'''
driver.close()

        

Output:
DevTools listening on ws://127.0.0.1:12452/devtools/browser/02a0e16e-e76a-41a6-850a-0229d267dbcf []
Reply


Messages In This Thread
RE: How to click the button automatically using python - by purnima1 - Dec-03-2017, 07:29 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  cant click button by script at page michael1834 1 1,123 Dec-08-2023, 04:44 PM
Last Post: SpongeB0B
  Click on a button on web page using Selenium Pavel_47 7 4,795 Jan-05-2023, 04:20 AM
Last Post: ellapurnellrt
  Show HTML in Python application and handle click SamHobbs 2 2,772 Sep-28-2021, 06:27 PM
Last Post: SamHobbs
  button click error rafarangel 2 3,171 Feb-11-2021, 08:19 PM
Last Post: buran
  Log In Button Won't Click - Python Selenium Webdriver samlee916 2 3,886 Jun-07-2020, 04:42 PM
Last Post: samlee916
  How to click facebook message button JanelleGuthrie 2 2,451 May-14-2020, 06:02 PM
Last Post: Larz60+
  Contact form button click action Man_from_India 1 2,837 Feb-01-2020, 06:21 PM
Last Post: snippsat
  HOWTO? Login DSL Modem with Python Requests: need Click "Apply" Button Webtest 4 8,560 Aug-20-2019, 04:03 PM
Last Post: johnmina
  Selenium click on popup button??? GuJu 7 8,051 Jul-20-2019, 09:21 AM
Last Post: Nizam
  How to trigger click event on Button without ID/Name gahhon 7 14,094 Feb-10-2019, 03:06 PM
Last Post: gahhon

Forum Jump:

User Panel Messages

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