1

I am new to python. I am following some examples found online to learn it.

One of the examples is to use "selenium"

The example use "find_element_by_link_text", But it seems to be missing. I have to use "find_element" option.

I am using following code, but it is giving me error. The Chrome browser does get open error is in find_element part. Can anyone provide some advice on how to fix it?

from selenium import webdriver

browser = webdriver.Chrome()

browser.get("https://github.com")
signin_link = browser.find_element("LINK_TEXT", "Sign in")

print(signin_link)
1
  • 2
    Your locator approach is incorrect. Either use BY. or text-only approach. See valid locators here: selenium.dev/selenium/docs/api/py/webdriver/… // Also, link the tutorial which you are following. The tutorial may be bad Commented Aug 9, 2022 at 16:58

1 Answer 1

0

Functions like find_element_by_x are not supported anymore since v4.0. Use the By class instead.

from selenium import webdriver
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager

browser = webdriver.Chrome(ChromeDriverManager().install())

browser.get("https://github.com")
signin_link = browser.find_element(By.LINK_TEXT, "Sign in")
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.