在Selenium python中按照xpath模式查找元素

2024-10-04 07:33:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用selenium python和莴苣来测试django应用程序。

以下模式中有许多元素具有xpath,我不知道文档中有多少元素。在

.//*[@id='accordion-note-1']
.//*[@id='accordion-note-2']
.//*[@id='accordion-note-3']
.//*[@id='accordion-note-4']

有没有办法在中使用patterndriver.find_元素
我的xpath基本上是为了得到所有的项目。在


Tags: 项目django文档id应用程序元素selenium模式
1条回答
网友
1楼 · 发布于 2024-10-04 07:33:36

不确定这是否有效,但您可以尝试使用以下xpath:

.//*[starts-with(@id, 'accordion-note')]

这是链接 http://www.zvon.org/xxl/XSLTreference/Output/function_starts-with.html

你也可以在这里使用contain like

^{pr2}$

相关问题 更多 >