Home > Software design >  How can I access link by selenium?
How can I access link by selenium?

Time:09-24

Problem : can not click link which is using javascript by selenium.

tried : 1. element = driver.find_element_by_css_selector(a {href: "javascript:void(0)"} SyntaxError: invalid syntax

  1. element = driver.execute_script("javascript_:void(0)") Nothing happened.

element <a href="javascript_:void(0)" onclick="changeVis('dnskvmenu', 'dnskvtree')">「戒蘊篇」</a>

How can I access link by selenium? How can I click that link? I have found similar problem but I can not understand answer. Does anyone know the reason of this problem? Or are there other ways to access the link?

enter image description here

CodePudding user response:

Find the element you want with nth-child, based on the div that the link is located in.

#sidebarElement a:nth-child(1)

  • Related