我试图找到与“Lønudvikling”相对应的元素,以便能够在以下页面上单击它:SIRKA
它装在一个液体容器中,可能以某种方式对其造成影响,但我不确定。
我尝试过
from selenium import webdriver
from bs4 import BeautifulSoup
#launch url
url = "https://www.krl.dk/#/sirka/"
# create a new Chrome session
driver = webdriver.Chrome('/usr/local/bin/chromedriver')
driver.implicitly_wait(20)
driver.get(url)
driver.find_element_by_partial_link_text('udvikling')
这是不对的,因为经过检查,我得到了该按钮的以下html:
<div ng-repeat="r in reports | orderBy : 'order'" ng- class="reports[model.report].id == r.id ? 'sirkaRapA' : 'sirkaRapU clickable'" ng-click="chReport(r.id)" ng-show="show(r)" class="ng-binding ng-scope sirkaRapU clickable">
所有按钮如下所示在容器中
<!-- ngRepeat: r in reports | orderBy : 'order' --><div ng-repeat="r in reports | orderBy : 'order'" ng-class="reports[model.report].id == r.id ? 'sirkaRapA' : 'sirkaRapU clickable'" ng-click="chReport(r.id)" ng-show="show(r)" class="ng-binding ng-scope sirkaRapA">
Lønniveau
<!-- ngIf: r.help -->
</div><!-- end ngRepeat: r in reports | orderBy : 'order' --><div ng-repeat="r in reports | orderBy : 'order'" ng-class="reports[model.report].id == r.id ? 'sirkaRapA' : 'sirkaRapU clickable'" ng-click="chReport(r.id)" ng-show="show(r)" class="ng-binding ng-scope sirkaRapU clickable">
Lønspredning
<!-- ngIf: r.help -->
</div><!-- end ngRepeat: r in reports | orderBy : 'order' --><div ng-repeat="r in reports | orderBy : 'order'" ng-class="reports[model.report].id == r.id ? 'sirkaRapA' : 'sirkaRapU clickable'" ng-click="chReport(r.id)" ng-show="show(r)" class="ng-binding ng-scope sirkaRapU clickable">
Lønudvikling
<!-- ngIf: r.help -->
</div><!-- end ngRepeat: r in reports | orderBy : 'order' --><div ng-repeat="r in reports | orderBy : 'order'" ng-class="reports[model.report].id == r.id ? 'sirkaRapA' : 'sirkaRapU clickable'" ng-click="chReport(r.id)" ng-show="show(r)" class="ng-binding ng-scope sirkaRapU clickable">
因为id = r.id?对于所有这些,我不确定如何找到特定的。
Særydelser
<!-- ngIf: r.help -->
</div><!-- end ngRepeat: r in reports | orderBy : 'order' --><div ng-repeat="r in reports | orderBy : 'order'" ng-class="reports[model.report].id == r.id ? 'sirkaRapA' : 'sirkaRapU clickable'" ng-click="chReport(r.id)" ng-show="show(r)" class="ng-binding ng-scope sirkaRapU clickable">
Antal ansatte
<!-- ngIf: r.help -->
</div><!-- end ngRepeat: r in reports | orderBy : 'order' --><div ng-repeat="r in reports | orderBy : 'order'" ng-class="reports[model.report].id == r.id ? 'sirkaRapA' : 'sirkaRapU clickable'" ng-click="chReport(r.id)" ng-show="show(r)" class="ng-binding ng-scope sirkaRapU clickable">
Beskæftigelsesgrad
Lønudvikling
<!-- ngIf: r.help -->
</div>
据我所知,“ udvikling”只是“显示”,而不是链接的一部分。 我也想知道我是否在正确的窗口中。
非常感谢您的帮助:)
答案 0 :(得分:0)
TARGET_B
和#if
只能用于链接(例如static func translateFromAnnuaireNode(annuaireNode: GetAnnuaireFromSearchQuery.Data.Directory.Edge.Node) -> ContactModel {
let contactModel = ContactModel()
contactModel._id = annuaireNode.id
#if TARGET_A
//The code here will only be compiled when building target A
contactModel.test = annuaireNode.test
#endif
return contactModel
}
)
您可以使用XPath搜索:
find_element_by_link_text()
或
find_element_by_partial_link_text()