简体   繁体   English

弹出窗口 window 无法单击模态下的确定按钮 window class - Selenium [JAVA]

[英]PopUp window not able to click on OK button which Is under Modal window class - Selenium [JAVA]

a popup that displayed while tried to change some data.尝试更改某些数据时显示的弹出窗口 that stored on Modal Dialog window存储在模态对话框 window

tried many times to click on [OK] but its not interact with element.多次尝试单击 [确定] 但它不与元素交互。

First within Click().首先在 Click() 中。 and then within Send Keys and its not worked..然后在 Send Keys 中并且它不起作用..

 div class="modal show" id="myModal-vechail" aria-modal="true" style="padding-right: 17px; display: block;"> <div class="modal-body bg-white"> <div class="row"> <div class="col-12 pt-2">You have changed vehicle model. Would you like to proceed?</div> <div class="col-12"> <div class="row pt-3 pb-2 justify-content-center"> <a href="javascript:void(0)" id="model-confirmed" tabindex="null" class="col-md-3 btn btn-primary btn-lg mr-md-3 step-control">Ok</a> <a href="javascript:void(0)" id="changeModelPopupCancel" tabindex="null" class="col-md-3 btn btn-primary btn-lg step-control" data-dismiss="modal">Cancel</a> </div> </div> </div> </div> </div>

and the source Code [ it is print the Body Text But not clicking on Ok button plus the Enter Key] :和源代码[它是打印正文但不点击确定按钮加回车键]

String s1= driver.findElement(By.xpath("//*[@id='myModal-vechail']/div/div/div[1]")).getText();
System.out.println(s1);
WebDriverWait wait = new WebDriverWait(driver, 2);
Thread.sleep(2000);
 
//driver.findElement(By.id("model-confirmed")).click();
Actions act = new Actions(driver);
act.sendKeys(Keys.TAB ).perform();
act.sendKeys(Keys.ENTER);

You could try with linkText as well.您也可以尝试使用linkText

WebDriverWait wait = new WebDriverWait(driver, 20);
wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Ok"))).click();

or with xpath:或使用 xpath:

wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//a[text()='Ok'and @id='model-confirmed']"))).click();

Try this:尝试这个:

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//div[@id='myModal-vechail']//*[contains(text(),'Ok')]"))).click();

SOLVED BY USING ".perform()"通过使用“.perform()”解决

act.sendKeys(Keys.ENTER).perform();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Java中使用Selenium在模态窗口中单击“确定”按钮? - How can I click an OK button in a modal window using selenium with java? 如何通过使用Java在Selenium Webdriver中的弹出窗口上单击允许按钮 - How to click on allow button on popup window in selenium Webdriver by using Java 如何通过使用Java在Selenium Webdriver中的弹出窗口上单击按钮 - How to click on button on Popup Window in Selenium Webdriver by using Java 单击主窗口中的单选按钮时,如何在子弹出窗口字段中输入数据并单击确定按钮 - How to enter data in child popup window fields and click ok button , when click radio button at main window 无法单击 Selenium Webdriver (Java) 中模态的“关闭”按钮 - Not able to click "Close" button of a Modal In Selenium Webdriver (Java) 在硒中,无法单击错误消息“确定”按钮 - In selenium, Not able to click on Error msg 'OK' button 无法单击上下文菜单 - 在 selenium Java 中的新 window 中打开链接 - Not able to Click on context Menu - Open link in new window in selenium Java Selenium RC无法使用下载弹出窗口 - Selenium RC not able to work with downloads popup window 用PhantomJS Selenium Java无法点击popup allert消息“OK或Cancel”,与IE一起正常工作 - Not able to click on popup allert message“OK or Cancel” with PhantomJS Selenium Java, working fine with IE 带有最大化按钮的Java模态窗口 - Java modal window with maximize button
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM