Python / Selenium - Chrome Web Driver, Click Action

I am having a problem encoding a click action with Selenium and the Chrome web driver in Python. I spent some time searching and found that I need to use a different selenium process to make a click in Google Chrome, which doesn't make sense to me (wouldn't it be when calling webdrive.Chrome?), Although I can't find any or another way to make a click, either online or through seleniums modules.

Here's what I have, any help is appreciated! Thank!

EDIT: So I found ActionChains module in Selenium can't seem to get this to work. Updated my code, a bit, still stuck. Does ChromeDriver really 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")]')

      

+3


source to share


1 answer


I hate it when such simple things are right in front of you.



clickme = browser.find_element_by_xpath('//a[contains(@href,"http://example.com/link")]')
clickme.click()

      

+3


source







All Articles