Python/Selenium - Chrome Web Driver, Click Action
11,827
I hate it when such simple things are right infront of you.
clickme = browser.find_element_by_xpath('//a[contains(@href,"http://example.com/link")]')
clickme.click()
Author by
Dustin
Updated on June 22, 2022Comments
-
Dustin almost 2 years
I'm having an issue coding a click action using Selenium and the Chrome Web Driver in Python. I've spent some time googling around and found that I have to use another selenium process in order to make a click in Google Chrome, which doesn't make sense to me (Wouldn't it be something while calling webdrive.Chrome?). Though I can't find any other method to make a click, either online or by going through seleniums modules.
Here's what I have, any help is appreciated! Thanks!
EDIT: So I found the ActionChains module in Selenium, can't seem to get this to work either. Updated my code, a bit, still stuck. Does the ChromeDriver really just not support clicks?
import selenium from selenium import webdriver from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.common.keys import Keys import time chromeOps = webdriver.ChromeOptions() chromeOps._binary_location = "C:\\Applications\\Browser\\Chrome.exe" chromeOps._arguments = ["--enable-internal-flash"] browser = webdriver.Chrome("C:\\Applications\\Browser\\chromedriver.exe", port=4445, chrome_options=chromeOps) time.sleep(3) browser.get("http://example.com") ##selenium.selenium("127.0.0.1", 4445,'*Chrome.exe', 'https://example.com').click("//a[contains(@href,'http://example.com/link')]") webdriver.ActionChains(browser).click(on_element='//a[contains(@href,"http://example.com/link")]')
-
dannyroa almost 12 yearsMaybe because he doesn't know. That's why he's asking.
-
Sandeep Raju Prabhakar almost 11 years@dannyroa hehe.. both the person who asked & answered are same :P