[英]Edureka - Handle exceptions in Selenium Web Driver - no print out
[英]how i can handle dynamic “Id” in Selenium web driver?
我如何處理Selenium Web驅動程序中的動態“ ID”,在我的Web表單中,當我創建會話的新會話ID時會有多個會話(例如,會話開始日期和會話結束日期)改變了我如何處理Selenium中的動態ID網絡驅動程序?
HTML代碼
<td id="_start_time_td_3" class="ui-widget-content">
<input type="text" id="_start_time_3"
name="start_time[]" maxlength="100" style="width: 120px;
text-align: left;" class="starttime" required="required">
</td>
硒代碼
driver.findElement(By.id("_start_time_1")).click();
driver.findElement(By.xpath("//div[10]/div/div[2]/table/tbody/tr/td[4]/div")).click();
driver.findElement(By.id("_end_time_1")).click();
driver.findElement(By.xpath("//div[11]/div/div[2]/table/tbody/tr/td[5]/div")).click();
您可以通過類名而不是ID選擇元素
driver.findElement(By.xpath("//input[@class='starttime']"));
或使用包含
driver.findElement(By.xpath("//input[contains(@id,'start_time')]"));
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.