【发布时间】:2018-06-27 09:53:26
【问题描述】:
我想处理此弹出窗口并单击取消按钮。我试过了,但它是不可点击的
弹出窗口的图像
我还添加了 Html 图片,请检查并告诉我解决方案
HTML 代码图像
测试用例在 Selenium 中传递,但没有点击。我将附上 Selenium 代码。
package Backendsite;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.support.PageFactory;
import org.openqa.selenium.support.ui.Select;
import org.testng.annotations.Test;
public class SkipTest {
@Test
public void f()
{
System.setProperty("webdriver.chrome.driver", "F:\\New folder\\chromedriver.exe");
//Setting To Open Incoginoto Window
ChromeOptions options = new ChromeOptions();
options.addArguments("-incognito");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver chromedriver=new ChromeDriver(capabilities);
chromedriver.manage().window().maximize();
//Opening The WebSite
chromedriver.get("xxxxxxxxxxxxxxxx");
chromedriver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
Pomsite p1 = PageFactory.initElements(chromedriver, Pomsite.class);
Select s1 = new Select(p1.getE1());
s1.selectByVisibleText("xxxxxxxxxx");
p1.getE2().click();
try
{
Actions a1 = new Actions(chromedriver);
a1.moveToElement(p1.getE3()).click(p1.getE4()).build().perform();
}
catch(Exception e)
{
System.out.println("Can't Click");
}
chromedriver.close();
}
}
Pageobject 模型类的第二个代码:
package Backendsite;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;
public class Pomsite
{
public WebElement getE1() {
return e1;
}
public WebElement getE2() {
return e2;
}
public WebElement getE3() {
return e3;
}
public WebElement getE4() {
return e4;
}
@FindBy(id="ddlstore")
private WebElement e1;
@FindBy(xpath="//input[@id='CustomPaging_GridView_gv_edit1_0']")
private WebElement e2;
@FindBy(xpath="/html/body/div[1]/div/div/div[3]")
private WebElement e3;
@FindBy(xpath="/html/body/div[1]/div/div/div[3]/button[2]")
private WebElement e4;
}
我的取消按钮弹出的 HTML 代码
<div class="modal-footer">
<span id="prcid" style="display:none;">processing...</span>
<button type="button" id="skipok" onclick="skipoverall(this)" class="btn btn-primary" data-id="10514438996">Ok</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
</div>
PS:我也尝试了警报和确认弹出窗口,它不起作用。
【问题讨论】:
-
请将 html 发布为有问题的格式化代码,而不是图片
-
@NitinSingh 我已按照您的要求附上了取消按钮的 HTML 代码。
-
上述弹窗是否会在某些操作后打开?
-
如果不工作,它给出的例外是什么
标签: html selenium selenium-webdriver