Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How find link element
#1
I want click on link with text "Toner"
from selenium import webdriver


adm ='http://10.27.20.49/web/guest/br/websys/webArch/mainFrame.cgi'
# create a new Firefox session
driver = webdriver.Chrome(r'C:\Users\me\Downloads\chromedriver.exe')
driver.implicitly_wait(30)
driver.maximize_window()
driver.get(adm)
# I try another options, but still not working
I_want_click_on_link = driver.find_element_by_link_text("Toner").click()
entire element below
<a href="javascript:wsMenu_jumpUrl('../../websys/webArch/getStatus.cgi#linkToner');" class="">Toner</a>
Error
Error:
raise exception_class(message, screen, stacktrace) selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"link text","selector":"Toner"} (Session info: chrome=80.0.3987.149)
Reply
#2
At first I wondered why you would have a 30 delay.
What is this site? I gave up waiting after a while.
good luck
Reply
#3
Hi

About this line driver.implicitly_wait(30), it's a mistake, would be driver.implicitly_wait(3)
About your question, I acess my printer via browser.

I need check all level of each Toner, I have 8 printers.
Reply
#4
If i do test local i can find the element with Toner text and click to execute the JavaScript code.
The test look like this.

local_javascript.html
<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <title>Title of the document</title>
  </head>
  <body>
   <h1>Hello world test</h1>
   <a href="javascript:alert('Hello World!');">Toner</a>
  </body>
</html>
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
import time

options = Options()
#options.add_argument("--headless")
#options.add_argument("window-size=398,256")
browser = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options)
browser.get('file:///E:/div_code/scrape/sel_screenhot/local_javascript.html')
time.sleep(5)
I_want_click_on_link = browser.find_element_by_link_text("Toner").click()
How dos rest of html look when load it browser?
http://10.27.20.49/web/guest/br/websys/webArch/mainFrame.cgi
Could try to locate bye CSS selector or Xpath,right click inspect when over tag in dev tools.
The Copy --> Selector or XPath.
Usage then is.
I_want_click_on_link = driver.find_element_by_css_selector('.something')
I_want_click_on_link[0].click()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to find element in a deeply nested html structure Orientation_group 5 1,284 Oct-09-2023, 10:13 AM
Last Post: Larz60+
  Selenium suddenly fails to find element Pavel_47 3 6,304 Sep-04-2022, 11:06 AM
Last Post: Pavel_47
  How to find link to video file from URL Pavel_47 38 11,168 Jun-28-2022, 10:55 AM
Last Post: Pavel_47
  Find element using xpath engli 3 3,941 May-20-2020, 08:56 AM
Last Post: Larz60+
  find element...click() dont work windows11 6 3,136 Apr-23-2020, 11:13 PM
Last Post: law
  Find Dynamic Input Element Class Problem wazacko 0 1,601 Apr-03-2020, 11:46 AM
Last Post: wazacko
  bypassing find element click() windows11 1 1,881 Apr-02-2020, 11:55 AM
Last Post: Larz60+
  How to find which frame/iframe my element belongs to? smaria 1 2,058 Nov-18-2019, 09:21 PM
Last Post: Larz60+
  get link and link text from table metulburr 5 6,281 Jun-13-2019, 07:50 PM
Last Post: snippsat

Forum Jump:

User Panel Messages

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