我不明白为什么当我翻到这页的时候
或者不管该网站的哪个页面,Selenium都不允许我在脚本上运行带有以下代码的“下一页”按钮:
next_page = browser.find_element_by_xpath('/html/body/div[2]/main/div/div[2]/farefinder-widget/div/div[2]/div[2]/div/div/core-pagination/div/div[2]/a')
next_page.click()
在HTML代码上:
<a ng-class="{'disabled': $ctrl.isLastPage($ctrl.currentPageIndex)}" ng-click="$ctrl.handleNextClick()" class="core-link"><span class="nav-label">Successivo</span><core-icon icon-id="glyphs.chevron-right" class="icon-22 fill-ryanair-bright-blue"><div><svg tabindex="-1" focusable="false" role="img"><use xlink:href="/it/it/voli-low-cost/?from=BGY&out-from-date=2018-09-01&out-to-date=2018-09-30&budget=60&trip-length-from=1&trip-length-to=3#glyphs.chevron-right" ng-href="/it/it/voli-low-cost/?from=BGY&out-from-date=2018-09-01&out-to-date=2018-09-30&budget=60&trip-length-from=1&trip-length-to=3#glyphs.chevron-right"></use></svg></div></core-icon></a>
然而,如果我把它写在shell上,奇怪的是,它确实起作用了,有相同的行。我也试着用time.sleep
给它一些时间,但是什么也没发生。你知道吗
此元素的分页似乎已禁用,即
<a ng-class="{'disabled': $ctrl.isLastPage....
。如果我单击父div,它对我有效,如下所示:或者,如果要使用xpath,只需删除最后一个“a”:
为了可读性,我推荐CSS选择器。你知道吗
编辑:您可能会遇到异常,因为元素不可见。只需将元素滚动到视图中。你知道吗
相关问题 更多 >
编程相关推荐