简体   繁体   English

Python,Selenium Webdriver:未为Firefox驱动程序加载跨度

[英]Python, Selenium Webdriver: Spans are not loaded for Firefox driver

I have a problem with Firefox driver to display spans for one of the popups of my site. 我的Firefox驱动程序有问题,无法显示我的网站之一弹出窗口的跨度。 I am not allowed to post images because of the reputation but here is the example how it looks like for Firefox and Chrome drivers: https://www.dropbox.com/s/6yzgi40xljpdyp5/spans.png 由于声誉原因,我不允许发布图像,但以下是Firefox和Chrome驱动程序的示例: https : //www.dropbox.com/s/6yzgi40xljpdyp5/spans.png

So for Firefox I need to modify my locator: 因此,对于Firefox,我需要修改定位器:

_apply_button = (By.XPATH, "//button[contains(text(), 'Apply')]")

It does not work in this way for Chrome so there is another version for Chromedriver: 它不适用于Chrome,因此Chromedriver还有另一个版本:

_apply_button = (By.XPATH, "//button[contains(span, 'Apply')]")

Is there a way to get the spans loaded properly? 有没有办法使跨度正确加载?

Any help will be appreciated. 任何帮助将不胜感激。

Try to select the element by link text : 尝试通过链接文本选择元素:

_apply_button = driver.find_element_by_link_text('Apply')

An other solution is the following: 其他解决方案如下:

_apply_button = (By.XPATH, "//button/span[contains(text(), 'Apply')]")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM