我正在使用Selenium IDE,试图让它单击页面中的特定搜索栏,但是每次刷新页面时,搜索栏的id都会发生变化。我没有其他独特的东西可以用于contains()。
<div class="ace_content" id="id-46319949-a1be-4d53-a2a8-fa644b37485b" style="margin-top: 0px; width: 764px; height: 60px; margin-left: 0px;">
这是HTML。有没有其他方法可以找到搜索栏?
发布于 2018-06-09 01:10:57
根据selenium docs,除了id之外,您还有各种选择器可供选择。您可以选择显示为静态的类:
driver.find_elements_by_class_name('ace_content')
如果页面上存在多个ace_content
div,只需获取find_elements_by_class_name
返回的列表的n-1个索引,就可以选择第n个div。
发布于 2018-06-09 02:07:00
已解决。我使用这个//*@class=' ace_content‘来标识这个xpath,因为ace_content是惟一的。
https://stackoverflow.com/questions/50764451
复制相似问题