2016-11-25 88 views
-1

我实现与网页工厂POM在我的项目 和我面临的一个问题维护设备的情况下快速失败关闭弹出窗口

有在这个页面中的应用程序页面后,“文件夹”链接时存在我点击这个弹出窗口打开 我必须搜索一个文件夹并选择这个(输入文件夹名称,选择单选按钮,点击开始按钮) 这是我能够做到的,但是当我点击Go按钮后全部填满这个弹出的数据 这弹出关闭和选定的数据显示在主页面上,但在此之后,我的下一个命令没有得到执行就像填充下一个fileds的值。

我打电话下面的方法在我的测试页

public void TabHandles() throws Throwable { 

    String currentWindowHandle = driver.getWindowHandle(); 

    //Get the list of all window handles 
    ArrayList<String> windowHandles = new ArrayList<String>(driver.getWindowHandles()); 

    for (String window:windowHandles){ 

    //if it contains the current window we want to eliminate that from switchTo(); 
    if (window != currentWindowHandle) 
    { 
    //Now switchTo new Tab. 
    driver.switchTo().window(window); 
    //Do whatever you want to do here. 
    //driver.close(); 


    driver.switchTo().defaultContent(); 
    } 

public ProfilePage CompleteUccForm() throws Throwable { 

    test.log(LogStatus.INFO, "Cliking in the UCC Tab"); 
    //upload.click(); 


    ucc.click(); 

    folder.click(); 


    //newttab(); 

    tabHandles(); 

    foldertext.sendKeys("Applesamsung"); 
    foldergo.click(); 
    folderradio.click(); 
    folderselect.click(); 

    // maintabttab(); 

    realestatecheck.click(); 
    contactname.sendKeys("deepak"); 
    relation.sendKeys("Lessee/Lessor"); 

和我的测试案例是越来越失败。与下面的错误---

FAILED: CompleteUccForm- 
org.openqa.selenium.NoSuchWindowException: Window not found. The browser window may have been closed. 
Command duration or timeout: 31 milliseconds 
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:55:52' 
System info: host: 'DS-E0699598D816', ip: '10.97.222.20', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_66' 
Driver info: org.openqa.selenium.firefox.FirefoxDriver 
Capabilities [{applicationCacheEnabled=true, rotatable=false, handlesAlerts=true, databaseEnabled=true, version=37.0.2, platform=WINDOWS, nativeEvents=false, acceptSslCerts=true, webStorageEnabled=true, locationContextEnabled=true, browserName=firefox, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}] 
Session ID: 6ca9a623-ea39-4c16-a7dd-e1b3f80afd04 
*** Element info: {Using=xpath, value=//*[@id='ctrlLien_lienHeadercontrol_chkFixture']} 
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) 

请回复我被困在这个问题,因为很长一段时间

+0

请格式化为正确发布,可能会有一些复制粘贴错误。 – aggsol

回答

1

弹出的窗口关闭后您需要再次运行SWITCHTO命令切换到您需要哪个窗口,然后网络驱动程序将能够找到您需要的元素并执行操作。

P.S:在出现弹出窗口之前,窗口ID存储在某个字符串变量中,一旦弹出窗口关闭,它将很容易再次切换回来。

0

driver.close();后执行driver.switchTo().window(currentWindowHandle);

它会做的工作。

+0

以上两个功能都无法正常工作,即使我也试过这个以及... –