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

mgdq6dx1  于 2023-09-29  发布在  Java
关注(0)|答案(1)|浏览(87)
<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();

我试着这样做,但没有工作,没有给任何错误

htrmnn0y

htrmnn0y1#

你可以在By.xpath()中做得更具体:

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

相关问题