【问题标题】:I am trying to create a selenium script but got stuck when i am trying to click on a button "Save".I have given below html available我正在尝试创建一个硒脚本,但是当我尝试单击“保存”按钮时卡住了。我在下面给出了可用的 html
【发布时间】:2015-02-17 13:38:45
【问题描述】:
<button id="ext-gen1546" autocomplete="off" role="button" hidefocus="true" type="button" style="width: 69px;">

<span id="ext-gen1548" class="x-btn-inner" 

style="width: 69px;">Save</span>
<span id="ext-gen1549" class="x-btn-icon">
</span>
</button>

上面是这个保存按钮的 HTML。 ID 是动态的
尝试使用类但无法找到元素。

【问题讨论】:

  • 你有什么问题?
  • 我无法在页面上找到保存按钮。找到后需要点击它来保存数据。

标签: java selenium


【解决方案1】:

你为什么不试试

driver.findElement(By.tagName("button"));

【讨论】:

  • 我尝试了下面的脚本,但这不起作用- WebElement element8 = D1.findElement(By.tagName("button")); element8.click();页面有Save和Exit两个按钮。需要标识Save然后点击
  • 你为什么不试试 List element8 = D1.findElements(By.tagName("button")); element8.get(0).click();
猜你喜欢
  • 1970-01-01
  • 2021-07-24
  • 2021-07-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-12-17
  • 2021-04-04
相关资源
最近更新 更多