I am trying to click the Gmail link on the Google homepage in Selenium using WebDriver in Python. My code basically repeats the one found here: Why can't I select an element in selenium?
My code is:
import selenium.webdriver as webdriver firefox = webdriver.Firefox() firefox.get("http://www.google.ca") element = firefox.find_element_by_xpath(".//a[@id='gb_23']") element.click()
Webdriver loads the page and then nothing happens. I tried using ActionChains and move_to_element (element), click (element) and then execute (), but nothing happens.
Use the find_element_by_id method:
find_element_by_id
element = firefox.find_element_by_id("gb_23") element.click()
or fix your xpath for:
"//a[@id='gb_23']"
Here you have a good tutorial.
try this because i dont see this id in html:
driver = webdriver.Firefox() driver.get("http://www.google.ca") element = driver.find_element_by_link_text("Gmail") element.click()
Source: https://habr.com/ru/post/1498746/More articles:moving between simple actions - androidngIf with evaluated variable as part of an expression - angularjsIs it safe to change values ββin HashBiMap? - javaHow do I get twilio to call an agent to connect to callers in a queue? - apiScala iterator: "you can never use an iterator after calling a method on it" - why? - iteratorDoes operator precedence match a string like a number? - pythonOpenFileDialog showing different files depending on the assembly for 32-bit or 64-bit architecture - .netImage Grid Fluid Layout (Responsive) - htmlSystem.InvalidCastException: The specified listing is not valid. error - c #Doctrine 2 DQL: as columns of the GROUP BY (STI) discriminator - ormAll Articles