【发布时间】:2018-03-29 13:40:24
【问题描述】:
对于我的练习,我必须使用 selenium 和 Chrome webdriver 以及 python 2.7 点击链接:
html文件结构如下:
<div class="leftside" >
<span class="spacer spacer-20"></span>
<a href="https://test.com" title="Retour à l'accueil"><img class="logo" src="https://img.test.com/frontoffice.png" /></a>
<span class="spacer spacer-20"></span>
<a href="https://test.com/console/index.pl" class="menu selected"><img src="https://img.test.com/icons/fichiers.png" alt="" /> Mes fichiers</a>
<a href="https://test.com/console/ftpmode.pl" class="menu"><img src="https://img.test.com/icons/publication.png" alt="" /> Gestion FTP</a>
<a href="https://test.com/console/remote.pl" class="menu"><img src="https://img.test.com/icons/telechargement-de-liens.png" alt="" /> Remote Upload</a>
<a href="https://test.com/console/details.pl" class="menu"><img src="https://img.test.com/icons/profil.png" alt="" /> Mon profil</a>
<a href="https://test.com/console/params.pl" class="menu"><img src="https://img.test.com/icons/parametres.png" alt="" /> Paramètres</a>
<a href="https://test.com/console/abo.pl" class="menu"><img src="https://img.test.com/icons/abonnement.png" alt="" /> Services Payants</a>
<a href="https://test.com/console/aff.pl" class="menu"><img src="https://img.test.com/icons/af.png" alt="" /> Af</a>
<a href="https://test.com/console/com.pl" class="menu"><img src="https://img.test.com/icons/v.png" alt="" /> V</a>
<a href="https://test.com/console/logs.pl" class="menu"><img src="https://img.test.com/icons/logs.png" alt="" /> Jour</a>
<a href="https://test.com/logout.pl" class="menu"><img src="https://img.test.com/icons/deconnexion.png" alt="" /> Déconnexion</a>
<span class="spacer spacer-20"></span>
<a href="#" id="msmall"><img src="https://img.test.com/btns/reverse.png"></a>
</div>
我使用:driver.find_element_by_xpath(),如下所述:enter link description here
driver.find_element_by_xpath('//[@id="leftside"]/a[3]').click()
但是我有这个错误信息:
语法错误:无法对“文档”执行“评估”:字符串 '//[@id="leftside"]/a[3]' 不是有效的 XPath 表达式。
谁能帮帮我?
问候
【问题讨论】: