因此,目前我正在使用python3和selenium webdriver和Salesforce来自动化管理验证。在
我已经相当成功了(尽管我不太精通编程)。但是,我遇到了一个问题。。。我似乎不知道如何在页面上找到一个元素,这样我就可以验证其中包含的文本是否被准确地显示出来。在
This is what it looks like on the user's end: The highlighted element displays as this
但每当我搜索“GlobalHeaderCommunitySwitcher”时,它会返回一个错误,即找不到它。在
所以我尝试在代码块中搜索其他元素:
<a href="javascript:void(0)" class="zen-trigger" aria-haspopup="true" id="globalHeaderCommunitySwitcher" title="Press space bar or Enter key to open" data-uidsfdc="51"><b class="zen-selectArrow"></b>PVT GBI Internal</a>
<b class="zen-selectArrow"></b>
"PVT GBI Internal"
我每次都是空着的,通过搜索:
browser.find_element_by_id("globalHeaderCommunitySwitcher") browser.find_element_by_class_name & used "zen-trigger" and "zen-selectArrow" browser.find_element_by_xpath("//div[@class='zen-trigger'and text()='PVT GBI Internal']")
这也会导致没有返回任何内容。。在
实际上,我如何通过上述代码在屏幕截图中找到元素,然后让脚本验证该元素(“PVT GBI INTERNAL”)中的文本是否存在且正确?
您可以使用
//tag[text()="value"] or //tag[contains(attribute,‘value’)]
示例:
browser.find_element_by_xpath("//a[@class='zen-trigger']//*[text()='PVT GBI Internal']")
说xpath
相关问题 更多 >
编程相关推荐