<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.5/react.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.5/react-dom.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/2.2.0/knockout-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.4.1/d3.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.20/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script>
<div class="cdk-overlay-container">
<div class="cdk-overlay-backdrop cdk-overlay-dark-backdrop cdk-overlay-backdrop-showing">
</div>
<div class="cdk-global-overlay-wrapper" style="justify-content: center; align-items: center;">
<div id="cdk-overlay-4" class="cdk-overlay-pane" dir="ltr" style="position: static; width: 500px; pointer-events: auto;">
<md-dialog-container class="mat-dialog-container" role="dialog">
<cdk-focus-trap>
<!--template bindings={}-->
<div tabindex="0">
</div>
<div class="cdk-focus-trap-content">
<!--template bindings={}-->
<app-dialog _nghost-wcd-65="">
<h1 _ngcontent-wcd-65="" md-dialog-title="" class="mat-dialog-title">
Confirm
</h1>
<hr _ngcontent-wcd-65="">
<div _ngcontent-wcd-65="" md-dialog-content="" class="mat-dialog-content">
Are you sure to become Tech Leader of 6757657?
</div>
<hr _ngcontent-wcd-65="" class="bottomLine">
<div _ngcontent-wcd-65="" class="bottomSection mat-dialog-actions" md-dialog-actions="">
<button _ngcontent-wcd-65="" class="btn">
Yes
</button>
<button _ngcontent-wcd-65="" class="btn" md-dialog-close="" type="button" aria-label="Close dialog">
No
</button>
</div>
</app-dialog>
</div>
<!--template bindings={}-->
<div tabindex="0">
</div>
</cdk-focus-trap>
</md-dialog-container>
</div>
</div>
</div>
&#13;
我不知道为什么它不想点击&#39;是&#39;显示的对话框上的按钮。 我的代码如下所示:
String parentWindowHandler = SeleniumExecutor.getDriver().getWindowHandle();
String subWindowHandler = null;
Set<String> handles =
SeleniumExecutor.getDriver().getWindowHandles();
Iterator<String> iterator = handles.iterator();
while (iterator.hasNext()) {
subWindowHandler = iterator.next();
}
SeleniumExecutor.getDriver().switchTo().window(subWindowHandler);
projectPage.confirmAddingTechLead();
SeleniumExecutor.getDriver().switchTo().window(parentWindowHandler);
}
public void confirmAddingTechLead(){
projectsPageLocators.yes_techLead.click();}
不知道为什么&#34;是&#34;元素没有定位,我认为我的定位器很好,它必须是handeling对话窗口,但我尝试了几种不同的方法,我总是得到以下错误:
rg.openqa.selenium.NoSuchElementException:没有这样的元素:无法 定位元素: {&#34;方法&#34;:&#34;的xpath&#34;&#34;选择器&#34;:&#34; HTML /体/格[2] / DIV [2] / DIV / MD-对话框的容器/ CDK-聚焦陷阱/ DIV [2] / APP-对话框/ DIV [2] /按钮[1]&#34;} (会议信息:chrome = 57.0.2987.98)(驱动信息: chromedriver = 2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform = Windows NT 10.0.14393 x86_64)(警告:服务器未提供任何堆栈跟踪信息)命令持续时间或超时:4.07秒For 有关此错误的文档,请访问: http://seleniumhq.org/exceptions/no_such_element.html构建信息: 版本:&#39; 3.0.1&#39;,修订版:&#39; 1969d75&#39;,时间:&#39; 2016-10-18 09:49:13 -0700&#39;系统信息:主机:&#39; LPACZEK-RZE&#39;,ip:&#39; 10.10.32.72&#39;,os.name:&#39; Windows 10&#39;,os.arch:&# 39; amd64&#39;,os.version:&#39; 10.0&#39;,java.version: &#39; 1.8.0_121&#39;驱动程序信息:org.openqa.selenium.chrome.ChromeDriver 功能[{applicationCacheEnabled = false,rotate = false, mobileEmulationEnabled = false,networkConnectionEnabled = false, 铬= {chromedriverVersion = 2.28.455520 (cc17746adff54984afff480136733114c6b3704b), userDataDir = C:\用户\ lpaczek \应用程序数据\本地\ TEMP \ scoped_dir2256_6186}, takesHeapSnapshot = true,pageLoadStrategy = normal, databaseEnabled = false,handlesAlerts = true,hasTouchScreen = false, version = 57.0.2987.98,platform = XP,browserConnectionEnabled = false, nativeEvents = true,acceptSslCerts = true,locationContextEnabled = true, webStorageEnabled = true,browserName = chrome,takesScreenshot = true, javascriptEnabled = true,cssSelectorsEnabled = true, unexpectedAlertBehaviour =}]会话ID: 1f5bf251b3097b95ce337030cad3fab8 ***元素信息:{Using = xpath,value = html / body / div [2] / div [2] / div / md-dialog-container / cdk-focus-trap / div [2] / app-dialog / DIV [2] /按钮[1]} at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native 方法)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) 在 sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) 在java.lang.reflect.Constructor.newInstance(Constructor.java:423)
在 org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216) 在 org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168) 在 org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:635) 在 org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:368) 在 org.openqa.selenium.remote.RemoteWebDriver.findElementByXPath(RemoteWebDriver.java:473) 在org.openqa.selenium.By $ ByXPath.findElement(By.java:361)at at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:360) 在 org.openqa.selenium.support.pagefactory.DefaultElementLocator.findElement(DefaultElementLocator.java:69) 在 org.openqa.selenium.support.pagefactory.internal.LocatingElementHandler.invoke(LocatingElementHandler.java:38) 在com.sun.proxy。$ Proxy14.getCoordinates(未知来源)at org.openqa.selenium.interactions.internal.MouseAction.getActionLocation(MouseAction.java:51) 在 org.openqa.selenium.interactions.MoveMouseAction.perform(MoveMouseAction.java:39) 在 org.openqa.selenium.interactions.CompositeAction.perform(CompositeAction.java:50) 在org.openqa.selenium.interactions.Actions.perform(Actions.java:373) 在 pages.executors.ProjectPage.confirmAddingTechLead(ProjectPage.java:99) at steps.EditProjectSteps.iClickYes(EditProjectSteps.java:138)at at ✽。我点击了 是(C:/Users/lpaczek/Documents/prome/src/test/resources/Task1/EditProject.feature:32)