Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How find link element
#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


Messages In This Thread
How find link element - by zinho - Mar-30-2020, 07:29 PM
RE: How find link element - by Larz60+ - Mar-31-2020, 03:28 AM
RE: How find link element - by zinho - Mar-31-2020, 11:08 AM
RE: How find link element - by snippsat - Mar-31-2020, 12:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to find element in a deeply nested html structure Orientation_group 5 1,634 Oct-09-2023, 10:13 AM
Last Post: Larz60+
  Selenium suddenly fails to find element Pavel_47 3 6,549 Sep-04-2022, 11:06 AM
Last Post: Pavel_47
  How to find link to video file from URL Pavel_47 38 11,991 Jun-28-2022, 10:55 AM
Last Post: Pavel_47
  Find element using xpath engli 3 4,075 May-20-2020, 08:56 AM
Last Post: Larz60+
  find element...click() dont work windows11 6 3,288 Apr-23-2020, 11:13 PM
Last Post: law
  Find Dynamic Input Element Class Problem wazacko 0 1,668 Apr-03-2020, 11:46 AM
Last Post: wazacko
  bypassing find element click() windows11 1 1,979 Apr-02-2020, 11:55 AM
Last Post: Larz60+
  How to find which frame/iframe my element belongs to? smaria 1 2,137 Nov-18-2019, 09:21 PM
Last Post: Larz60+
  get link and link text from table metulburr 5 6,489 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