0
當我的鏈接點擊,彈出打開。然而由於量角器無法定位元素,所以無法在彈出的字段上工作,然後獲取超時。不能切換到彈出窗口中量角器
以下是代碼 browser.ignoreSynchronization = TRUE;
performancePage.go();
logger.info('Info', 'Navigating to performance Page');
helper.isElementVisible(performancePage.performanceTab);
performancePage.performanceTab.click();
element(by.id("ButtonAddProduct")).click();
browser.driver.sleep(4000)
var handlePromise = browser.getAllWindowHandles();
var handles = handlePromise.then(function (handles) {
console.log(handles)
popUpHandle = handles[1];
var handle = browser.switchTo().window(popUpHandle);
handle = browser.getWindowHandle();
expect(handle).toEqual(popUpHandle);
browser.driver.executeScript('window.focus();');
});
//helper.isElementVisible(performancePage.addProduct);
//performancePage.addProduct.click();
helper.isElementVisible(element(by.id("form1")));[![enter image description here][1]][1]
中的console.log
此外,其只顯示1個窗口句柄,而不是彈出手柄
這裏是HTML:
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1">
<body>
<form id="form1" onsubmit="javascript:return WebForm_OnSubmit();" action="AddProduct.aspx" method="post">
<div class="aspNetHidden">
<script type="text/javascript"> //<![CDATA[ var theForm = document.forms['form1']; if (!theForm) { theForm = document.form1; } function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTARGET.value = eventTarget; theForm.__EVENTARGUMENT.value = eventArgument; theForm.submit(); } } //]]> </script>
<script type="text/javascript" src="/WebResource.axd?d=NLOzwancrFW_OxVrAGBXy-kmkOGHUYmO808scG3GJ5f98I_P9beUOmU4HNGkqJQWHiSPU9aY7onPaiTvMCtL3eBXmC_rcSTJAFJAPa_OIJw1&t=635586505120000000"/>
<script type="text/javascript" src="/ScriptResource.axd?d=K0uQ-qcyckZQ0YCESuG4YfaXFE8emO5C9Ce1KC27_VB1FRGUsYkGZcC6OJnVnIEp6qunwr4jFBAKcuX_FFlQhtiSBdTz0RYmzsqtrKC3ePqj2CqtZGDAEZ4f0TCoYf0CGDgUxlJb7An1eoe5Vvcd-YsPSDf93ysj0hatMJcw5Bk1&t=5303ace5"/>
<script type="text/javascript" src="/ScriptResource.axd?d=ICFVFfrCSHOWqdP0dm99rLOsC2_-ZnYiCw1CqjXgfBZ92x5ruBu78fP6ZyV7fADUc626lvSvIubJzd5ej_JSkHNQHZSSai511-4rfVoNIRmTJczCHqrBjZa3yIX-22uMxb3rGnoSAGlTcOHE53z7TSmGu1MNobwW3y3pLnoN-H72LyOhX5OECQ17aAmZHECd0&t=7b689585"/>
<script type="text/javascript"> //<![CDATA[ if (typeof(Sys) === 'undefined') throw new Error('ASP.NET Ajax client-side framework failed to load.'); //]]> </script>
<script type="text/javascript" src="/ScriptResource.axd?d=OL2ISgjqQODB5nkx4b5_GOgoAHxOq6FEk9tXBRu0WSmyCZCd3ccx73Jhlea-pmk11_GS4uVKb8o448Z76ihbV5xUGrVOtwriFbjM0joyKwz96l4gVfykwP91DaSn6g66OedAzY_pkY4s5--Zg_vgtAu4W2Kz6hrDw12cq5mZa1pji5zdqGZ-ZKisFszMRWz10&t=7b689585"/>
<script type="text/javascript"> //<![CDATA[ function WebForm_OnSubmit() { if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false; return true; } //]]> </script>
<div class="aspNetHidden">
<div style="margin: 4px">
<script type="text/javascript"> //<![CDATA[ Sys.WebForms.PageRequestManager._initialize('Scriptmanager1', 'form1', [], [], [], 90, ''); //]]> </script>
<table>
<tbody>
<tr>
<td>
<td>
<input id="TextBoxProductName" type="text" name="TextBoxProductName"/>
<span id="RequiredFieldValidator1" style="visibility:hidden;">
<br/>
Please enter a product name.
</span>
</td>
</tr>
<tr>
<td>
<b>
Product Short Name
<img id="Img4" src="../Images/Asterisk.gif"/>
</b>
</td>
<td>
<input id="TextBoxShortName" type="text" name="TextBoxShortName"/>
<span id="RequiredFieldValidator2" style="visibility:hidden;">
<br/>
Please enter a product short name.
</span>
</td>
</tr>
這很難說,這是怎麼回事,而不會看到HTML ... – Brine
已添加的HTML –
對不起anuvrat,我不能肯定提供的代碼有什麼問題。 'getAllWindowHandles'說只有一個窗口?這是一個彈出窗口,警報還是模態? – Brine