【发布时间】:2018-04-26 00:17:27
【问题描述】:
每次 SalesForce 发布新版本时,salesforce 网页上的大部分元素 ID 都会发生变化(我使用元素的 ID 属性通过我的自动化代码来定位它)。这会破坏我的自动化脚本。
在我的例子中,一个名为“问题名称”的文本框我想在这个文本框中输入一个值。
最近的html:
<label class="label inputLabel uiLabel-left form-element__label uiLabel" for="7:1781;a" data-aura-rendered-by="1040:0" data-aura-class="uiLabel">
<span class="" data-aura-rendered-by="1041:0">Question Name</span>
<span class="required " data-aura-rendered-by="8:1781;a">*</span>
</label>
<input id="7:1781;a" class=" input" maxlength="80" aria-describedby="" placeholder="" required="" data-aura-rendered-by="11:1781;a"
data-interactive-lib-uid="5" aria-required="true" type="text">
我现有的 xpath:
driver.findElement(By.xpath("//input[@id='6:2634;a']")).sendKeys("test");
Salesforce 应用程序的所有 ID 都会针对每个新版本动态更改,我的测试脚本因上述带有 ID 的 xpath 而失败,所以请建议我替代解决方案。
我应该如何在运行时获取输入 id 值?或者让我知道是否还有其他可能。
【问题讨论】:
标签: java selenium xpath selenium-webdriver salesforce