Я новичок в селене, поэтому очень ограниченные знания о селене. Здесь я столкнулся с периодической проблемой тайм-аута для inte rnet explorer. Я пробовал увеличить таймаут, но иногда это терпит неудачу. Трассировка стека ошибок:
org.openqa.selenium.TimeoutException: ожидаемое условие не выполнено: ожидание выполнения всех условий: видимость всех элементов, расположенных By.xpath: / // table [@ class = 'urMatrixLayout urHtmlTableReset'] // tr // table // tr // td // div // div / span [contains (text (), 'Violations')] && элемент, на который нужно щелкнуть: By.xpath: / // table [@ class = 'urMatrixLayout urHtmlTableReset'] // tr // table // tr // td // div // div / span [contains (text (), 'Violations') )] (пыталось 120 секунд с интервалом 1000 миллисекунд) Информация о сборке: версия: '3.141.59', редакция: 'e82be7d358', время: '2018-11-14T08: 17: 03' Информация о системе: хост: 'WIN-2PRR06VLLD C', ip: 'xxx.xxx.xx.xx', os.name: 'Windows Server 2019', os.arch: 'amd64', os.version: '10 .0 ', java .version: '1.8.0_241' Информация о драйвере: org.openqa.selenium. ie .InternetExplorerDriver Capabilities {browserAttachTimeout: 0, browserName: inte rnet explorer, elementScrollBehavior: 0, enableElementCacheCleanup: true, enablePersistentHover: enablePersistent false, ie .browserCommandLineSwitches:, ie .enableFullPageScreenshot: true, ie .ensureCleanSession: true, ie .fileUploadDialogTimeout: 3000, ie .forceCreateProcessApi: ignoreSettings: false : true, ignoreZoomSetting: true, initialBrowserUrl:, javascriptEnabled: true, nativeEvents: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, requireWindowFocus: false, unknownAlertBehaviour: dismiss, unhandledPromptBehavior: 11
Я реализовал код следующим образом:
public static void clickOnElement(By element, String comment, WebDriver driver) {
WebDriverWait wait = new WebDriverWait(driver, 120);
wait.pollingEvery(1000, TimeUnit.MILLISECONDS);
wait.ignoring(NoSuchElementException.class);
wait.ignoring(StaleElementReferenceException.class);
wait.until(ExpectedConditions.and(ExpectedConditions.visibilityOfAllElementsLocatedBy(element),
ExpectedConditions.elementToBeClickable(element)));
WebElement context = driver.findElement(element);
wait.until(new ExpectedCondition<Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
return ((JavascriptExecutor) driver).executeScript("return document.readyState").equals("complete");
}
});
driver.manage().timeouts().pageLoadTimeout(120,TimeUnit.SECONDS);
context.click();
log.info("Clicked on element " + comment);
}
Любая помощь будет принята с благодарностью. Заранее спасибо !!
Html tree:
`<table cellspacing="0" cellpadding="0" id="WDCC" ct="ML" lsdata="
{0:'WDCC',7:'LINE'}" class="urMatrixLayout urHtmlTableReset"
role="presentation" border="0" style="border-collapse:collapse;">
<tbody class="urLinStd">
<tr>
<td ct="MLC" lsdata="{}" id="WDCE" valign="baseline" align="left"
class="urLayoutDefault" style="border-collapse:separate;white-
space:normal;"><label ct="L" lsdata="
{1:'WDD1',3:'Business\x20Process',4:true,11:'ENDOFLINE',12:true}"
id="WDCF" f="WDD1" class="urL" style="text-align:right;line-
height:normal;display:inline-block;min-width:100%;white-space:nowrap;">
<span class="urLblReq">*</span> Business Process:</label></td>
<td ct="MLC" lsdata="{}" id="WDD0" valign="baseline" align="left"
class="urLayoutDefault" style="border-collapse:separate;white-
space:normal;">
<span id="WDD1-r" class="urCoB2Whl ">
<input id="WDD1" ct="CB" lsdata="
{4:true,7:'WDD2',8:'Basis',10:'Basis'}" lsevents="{Select:
[{ResponseData:'delta',ClientAction:'submit'},{}]}" type="text"
autocomplete="off" tabindex="0" ti="0" class="urEdf2TxtRadius
urEdf2TxtEnbl lsEdf3TxtHlpBtn lsEdfLeftBrdRadius urBorderBox"
readonly="" value="Basis" role="combobox" style="width:125px;">
<div id="WDD1-btn" tabindex="-1" ti="-1" class="lsEdf3HlpBtnStd
urBorderBox lsEdf2HlpRadius lsEdf3HlpIcon lsEdf3HlpBtn lsEdf3HlpBtnCoB"
role="button" style="display:inline-block;"></div>
</span>
</td>
</tr>
<tr>
<td ct="MLC" lsdata="{}" id="WDE1" valign="baseline" align="left"
class="urLayoutDefault" style="border-collapse:separate;white-
space:normal;"><label ct="L" lsdata="
{1:'WDE4',3:'Functional\x20Area',11:'ENDOFLINE',12:true}" id="WDE2"
f="WDE4" class="urL" style="text-align:right;line-
height:normal;display:inline-block;min-width:100%;white-
space:nowrap;">Functional Area:</label></td>
<td ct="MLC" lsdata="{}" id="WDE3" valign="baseline" align="left"
class="urLayoutDefault" style="border-collapse:separate;white-
space:normal;">
<span id="WDE4-r" class="urCoB2Whl ">
<input id="WDE4" ct="CB" lsdata="{7:'WDE5',10:'Select'}"
lsevents="{Select:[{ResponseData:'delta',ClientAction:'submit'},{}]}"
type="text" autocomplete="off" tabindex="0" ti="0"
class="urEdf2TxtRadius urEdf2TxtEnbl lsEdf3TxtHlpBtn lsEdfLeftBrdRadius
urBorderBox" readonly="" value="Select" role="combobox"
style="width:125px;">
<div id="WDE4-btn" tabindex="-1" ti="-1" class="lsEdf3HlpBtnStd
urBorderBox lsEdf2HlpRadius lsEdf3HlpIcon lsEdf3HlpBtn lsEdf3HlpBtnCoB"
role="button" style="display:inline-block;"></div>
</span>
</td>
</tr>
</tbody>
</table>
</div></div></td></tr></tbody></table></div></div></td></tr></tbody>
</table></div></td></tr></tbody></table></td></tr></tbody></table></div>
</td></tr></tbody></table></span></span></td></tr></tbody></table></td>
</tr>
<tr>
<td ct="MLC" lsdata="{}" id="WDE8" valign="bottom" align="left"
class="urLayoutPadless" style="border-
collapse:separate;width:100%;height:5px;white-space:normal;">
<div id="WDEA-r">
<table cellspacing="0" cellpadding="0" id="WDEA" ct="ML" lsdata="
{0:'WDEA',7:'LINE'}" class="urMatrixLayout urHtmlTableReset"
role="presentation" border="0" style="border-collapse:collapse;">
<tbody class="urLinStd">
<tr>
<td></td>
</tr>
</tbody>
</table>
</div>
</td>
</tr>
<tr>
<td ct="MLC" lsdata="{}" id="WDEC" valign="bottom" align="left"
class="urLayoutPadless" style="border-
collapse:separate;width:100%;white-space:normal;">
<table border="0" cellpadding="0" cellspacing="0" id="WDED" ct="TS"
lsdata="{2:'100\x25',3:'Choose\x20Tab',6:true,7:false,8:false}"
lsevents="{TabSelect:[{ResponseData:'delta',ClientAction:'submit'},
{}],Scroll:[{ResponseData:'delta',EnqueueCardinality:'single'},
{}],Hotkey:[{ResponseData:'delta',ClientAction:'submit'},{}]}" class=""
role="presentation" style="width:100%;" tabindex="-1" ti="-1">
<tbody>
<tr>
<td valign="bottom" class="lsTbsPanelCnt">
<table cellpadding="0" cellspacing="0" border="0"
style="width:100%;">
<tbody>
<tr>
<td class="lsTbsPanelLeftBtns" align="left"><a
class="lsTbsPgPrevLeftDisp lsTbsBtnIcon" tabindex="-1" ti="-1"
id="WDED-prevLeft" style="visibility:hidden;"></a></td>
<td class="lsTbsPanel2" width="90%">
<span itn="ITBB" id="WDED-ITBB" tabindex="0" ti="0"
style="position:absolute;top:-1000;height:1;"></span>
<div id="WDED-panel" class="lsTbsOvfl" role="tablist" aria-
controls="" style="float:left;">
<div ct="TSITM" lsdata="{0:'WDEE',2:true,12:'WDEF'}" id="WDEE"
class="lsTbsEndMore2Sel" style="visibility: visible;">
<span class="lsTbsFirst2Sel"></span>
<span role="tab" id="WDEE-focus" tabindex="0" ti="0"
class="urNoUserSelect lsTbsLabel2Sel">
User Access
<div class="lsTbsTitleAlign" aria-hidden="true"
role="presentation">User Access-</div>
</span>
</div>
<div ct="TSITM" lsdata="{0:'WD01B0',1:1,2:true,12:'WD01B1'}"
id="WD01B0" class="lsTbsEndMore2" style="visibility: visible;">
<span class="lsTbsStartEnd2Sel"></span>
<span role="tab" id="WD01B0-focus" tabindex="0" ti="0"
class="urNoUserSelect lsTbsLabel2">
Violations
<div class="lsTbsTitleAlign" aria-hidden="true"
role="presentation">Violations-</div>
</span>`
Xpath: / * // table [@ class = 'urMatrixLayout urHtmlTableReset'] // tr // table // tr // td // div // div / span [содержит (text (), 'Violations')]