selenium 2.0 for IE8 遇到的问题总结

上一篇 / 下一篇  2013-01-22 11:51:51 / 个人分类:单元测试

import java.io.File;
import java.util.concurrent.TimeUnit;
import org.junit.*;
import org.openqa.selenium.*;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;

public class GoogleDemo {
    private static WebDriver driver;
      
    @Before
    public void setUp() throws Exception {

        System.setProperty("webdriver.ie.driver","D:\\Selenium\\IEDriverServer\\IEDriverServer.exe");
        DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
        ieCapabilities.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS,true);
        driver = new InternetExplorerDriver(ieCapabilities);
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);

    }
    
    @Test
      public void testA() throws Exception {
        driver.get("http://www.google.co.in/");
        WebElement SearchInputElem = driver.findElement(By.id("gbqfq"));
        oSearchInputElem.sendKeys("selenium");
        WebElement GoogleSearchBtn = driver.findElement(By.name("btnK"));  
        oGoogleSearchBtn.click();
      }
    
    @After
    public void tearDown() throws Exception {
        driver.quit();
    }
}

错误提示: Unable to find element with id == gbqfq (WARNING: The server did not provide any stacktrace information)
解决方案:
Please make sure you're using the latest gems and that Internet Options -> Security has the same Protected Mode setting (on or off, it doesn't matter as long as it is the same value) for all zones.

 

2.ant 编译时遇到  java.lang.NoClassDefFoundError: com/google/common/base/Charsets 异常:

解决方案:将selenium-server路径加入junit的classpath中 


3.otFoundException: Unexpected error launching Internet Explorer. Browser zoom level was set to 109%. It should be set to 100% (WARNING: The server did not provide any stacktrace information)


"Open Regedit and navigate to HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\Zoom. In the right-hand pane is a listing for ZoomFactor. Double-click on it and click the button next to Decimal. Change the value from 110000 to 100000, click OK, and exit Regedit. Now every time you open IE, it should be zoomed into 150%. This will also zoom any new tabs that are opened."


http://www.cnblogs.com/nbkhic/archive/2011/10/27/2227028.html



TAG:

ewwerpm的个人空间 引用 删除 ewwerpm   /   2016-02-09 11:23:13
第三个问题解决方案确实有效
 

评分:0

我来说两句

Open Toolbar