Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用selenium RC和Java处理弹出窗口_Java_Selenium_Selenium Rc - Fatal编程技术网

如何使用selenium RC和Java处理弹出窗口

如何使用selenium RC和Java处理弹出窗口,java,selenium,selenium-rc,Java,Selenium,Selenium Rc,我正在尝试自动化电子商务网站&我有一个问题如何处理弹出窗口。请看一看这个场景 去 在产品页面上,单击“添加到购物车”按钮(这将向购物车添加产品并显示弹出窗口) 在弹出窗口中,我想单击“签出”按钮(这将关闭弹出窗口) 我坚持第3点,错误是找不到元素 这是我写的东西 @试验 公共无效angara_Home_product(){ }使用以下代码: 我认为在第2步之后应该有wait命令,并且我已经为第3步编辑了xpath selenium.click("xpath=//span[contains(tex

我正在尝试自动化电子商务网站&我有一个问题如何处理弹出窗口。请看一看这个场景

  • 在产品页面上,单击“添加到购物车”按钮(这将向购物车添加产品并显示弹出窗口)

  • 在弹出窗口中,我想单击“签出”按钮(这将关闭弹出窗口)

  • 我坚持第3点,错误是找不到元素

    这是我写的东西

    @试验 公共无效angara_Home_product(){

    }使用以下代码: 我认为在第2步之后应该有wait命令,并且我已经为第3步编辑了xpath

    selenium.click("xpath=//span[contains(text(),'Tanzanite Pendant')]");
     selenium.waitForPageToLoad("30000");
     assertTrue(selenium.isTextPresent("Pear Tanzanite and Diamond V-Bale Pendant"));
     selenium.click("xpath=//img[@class='imgsize']/@src[1]");
     selenium.click("css=#option-list-tab272 > span");
     selenium.click("xpath=//div[@id='option-container3341']/div/div/span");
     selenium.click("css=#option-list-tab332 > span");
     selenium.click("xpath=//span[contains(text(),'14K Yellow Gold')]");
     selenium.click("//input[@name='addToCartSubmit' and @value='ADD TO CART']");
    selenium.waitForPageToLoad("10000");
    
          //Some code should be there which might handle the pop-up window.
    
     selenium.click("xpath=//form[@id='updatepost_form']//*[@id='cart-top-checkout-button']");
     selenium.waitForPageToLoad("30000");
     assertTrue(selenium.isTextPresent("Express Checkout"));
    

    当我使用你的代码时出现10000毫秒错误后超时。你能使用Thread.sleep(10000)吗;而不是硒。waitForPageToLoad(“10000”);你能告诉我你现在遇到了什么错误吗?Sumit,我已经使用了下面的代码,现在它正在工作。尝试{Thread.sleep(10000);}catch(InterruptedException e){//TODO自动生成的catch块e.printStackTrace();}
    selenium.click("xpath=//span[contains(text(),'Tanzanite Pendant')]");
     selenium.waitForPageToLoad("30000");
     assertTrue(selenium.isTextPresent("Pear Tanzanite and Diamond V-Bale Pendant"));
     selenium.click("xpath=//img[@class='imgsize']/@src[1]");
     selenium.click("css=#option-list-tab272 > span");
     selenium.click("xpath=//div[@id='option-container3341']/div/div/span");
     selenium.click("css=#option-list-tab332 > span");
     selenium.click("xpath=//span[contains(text(),'14K Yellow Gold')]");
     selenium.click("//input[@name='addToCartSubmit' and @value='ADD TO CART']");
    selenium.waitForPageToLoad("10000");
    
          //Some code should be there which might handle the pop-up window.
    
     selenium.click("xpath=//form[@id='updatepost_form']//*[@id='cart-top-checkout-button']");
     selenium.waitForPageToLoad("30000");
     assertTrue(selenium.isTextPresent("Express Checkout"));