selenium java 中没有 id 或名称的按钮的路径

Path for button without id or name in selenium java

提问人:Rajeesha R 提问时间:9/25/2023 最后编辑:ShawnRajeesha R 更新时间:9/25/2023 访问量:21

问:

<span class=“MuiButton-label">
<span class="MuiButton-startIcon MuiButton-iconSizeMedium”>
<span class=“MuiButton-label"> <span class="MuiButton-startIcon MuiButton-iconSizeMedium”> <svg class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium css-vubbuv" focusable="false" aria-hidden="true" viewBox="0 enter code here0 24 24" data-testid=“SaveIcon"> <path d="somevalue”> Create

如何为上述代码创建路径?

driver.findElement(By.xpath("//*[contains(text(),'Create')]")).click();

我尝试过这样,但没有工作,也没有给出任何错误

java selenium-web驱动程序

评论


答:

0赞 Diego Borba 9/25/2023 #1

您可以在以下方面更具体地做到这一点:By.xpath()

driver.findElement(By.xpath("//span[contains(@class, 'MuiButton-label') and contains(text(),'Create')]")).click();