首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在firefox浏览器中使用selenium进行自动化测试

在firefox浏览器中使用selenium进行自动化测试
EN

Stack Overflow用户
提问于 2014-03-23 04:57:14
回答 1查看 191关注 0票数 0

我下载了下面的代码,并将其用于一些测试,u=it昨天运行了,但从今天开始,代码停止工作。我的测试现在失败了,这是以前没有发生过的。它抛出一个错误,指出org.openqa.selenium.ElementNotVisibleException:元素当前不可见,因此无法与元素交互。

代码语言:javascript
复制
package org.openqa.selenium.example;

//import org.openqa.selenium.browserlaunchers.locators.GoogleChromeLocator;

//import java.util.regex.Pattern;
import java.util.concurrent.TimeUnit;

import org.junit.*;

import static org.junit.Assert.*;

//import org.openqa.selenium.*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
//import org.openqa.selenium.chrome.*;
import org.openqa.selenium.firefox.*;
import org.openqa.selenium.firefox.FirefoxDriver;
//import org.openqa.selenium.support.ui.Select;
//import org.openqa.selenium.net.UrlChecker;

import static org.junit.Assert.assertEquals;


import org.junit.Test;

public class KongaUrlTest 
{

      private WebDriver driver;
      private String baseUrl;
      //private boolean acceptNextAlert = true;
      private StringBuffer verificationErrors = new StringBuffer();

      @Before
      public void setUp() throws Exception 
      {
        driver = new FirefoxDriver();
        baseUrl = "http://www.konga.com/";
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
      }

      @Test
      public void testFirefoxWebdriver() throws Exception 
      {
        driver.get(baseUrl);
        driver.findElement(By.cssSelector("a.vertnavlink > span")).click();
        try 
        {
          assertEquals("Phones & Tablets | Konga Nigeria", driver.getTitle());
          System.out.println(driver.getTitle());
        } 
        catch (Error e) 
        {
          verificationErrors.append(e.toString());
        }
      }

      @After
      public void tearDown() throws Exception 
      {
        System.out.println(driver.getCurrentUrl());
        driver.quit();

      }



}
EN

回答 1

Stack Overflow用户

发布于 2014-03-23 05:36:02

正在显示阻止对话框。它可能会在Selenium每次打开新浏览器并导航到该站点时显示。首先关闭该对话框:

代码语言:javascript
复制
driver.get(baseUrl);
try
{
    driver.findElement(By.cssSelector(".fancybox-close")).click();
}
catch { }
driver.findElement(By.cssSelector("a.vertnavlink > span")).click();
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22583490

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档