Python 使用selenium查找具有onclick属性的所有元素?

Python 使用selenium查找具有onclick属性的所有元素?,python,webdriver,selenium-chromedriver,Python,Webdriver,Selenium Chromedriver,我试图使用xpath和属性来查找\u元素,即onclick 示例元素: < a href = "#" onclick = "javascript:ValidateLink(&quot;FNOSquareOffBuySell&quot;,&quot;NATMIN,NFO,8503107736,S,6000,0,30-Aug-2018,E,11500,C,O,S,E,*,35,0,0,0,0,0,,,0,118.85,0,,,*,*,,NVTC&

我试图使用
xpath
属性
查找\u元素
,即
onclick

示例元素:

< a
    href = "#"
    onclick = "javascript:ValidateLink(&quot;FNOSquareOffBuySell&quot;,&quot;NATMIN,NFO,8503107736,S,6000,0,30-Aug-2018,E,11500,C,O,S,E,*,35,0,0,0,0,0,,,0,118.85,0,,,*,*,,NVTC&quot;)" >
    Square & nbsp;
    Off < / a >

我想找到元素,然后获取onclick属性文本,并使用它来决定要单击哪个元素。

您是否尝试过
/*[@onclick]
查找所有onclick元素

另外,您还为
“//*contains(@onclick,\'FNOSquareOffBuySell\'”)创建了一个类型“
, 你是说
/*[包含(@onclick,\“FNOSquareOffBuySell\”)

/*包含(@onclick,'FNOSquareOffBuySell"')]

ch = driver.find_elements_by_xpath("//*contains(@onclick,\"FNOSquareOffBuySell&quot\")]")

ch = driver.find_elements_by_xpath("//*[contains(@onclick)]")