启动浏览器笔记

一,准备文件 :

准备两个包在eclipsefileslib

Lib下面

log4j-1.2.17.jar

selenium-server-standalone-2.44.0.jar

files文件:

 

二,代码

代码:

package webdriver;

 

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.WebDriver.Navigation;

import org.openqa.selenium.chrome.ChromeDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.openqa.selenium.ie.InternetExplorerDriver;

import org.openqa.selenium.remote.DesiredCapabilities;

 

public class day001 {

public static void main(String[] args) {

mychrome();

myfirefox();

myie();

}

//火狐浏览器

public static void myfirefox(){

WebDriver driver=new FirefoxDriver();

Navigation Navigation=driver.navigate();

Navigation.to("http://nkweb-uat.huawei.com/tkb");

//driver.navigate().to("http://nkweb-uat.huawei.com/tkb");

 

// driver.get("http://nkweb-uat.huawei.com/tkb");

//driver.close();

// driver=null;

}

 

//谷歌浏览器

public static void mychrome(){

System.setProperty("webdriver.chrome.driver","files/chromedriver.exe");

WebDriver driver=new ChromeDriver();

Navigation Navigation=driver.navigate();

Navigation.to("http://nkweb-uat.huawei.com/tkb");

//driver.get("http://nkweb-uat.huawei.com/tkb");

}

 

//IE浏览器

public static void myie(){

System.setProperty("webdriver.ie.driver","files/IEDriverServer.exe");

//设置关闭模式

  DesiredCapabilities dcb = DesiredCapabilities.internetExplorer();

    dcb.setCapability("InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS",true);

        dcb.setCapability("ignoreProtectedModeSettings", true);

        WebDriver driver = new InternetExplorerDriver(dcb);

//WebDriver driver=new InternetExplorerDriver();

     Navigation Navigation=driver.navigate();

Navigation.to("http://nkweb-uat.huawei.com/tkb");

//driver.get("http://nkweb-uat.huawei.com/tkb");

}

}

三,问题及解决方法

操作期间注意:

1, 报错:会报错谷歌必须大于39版本的

解决方法:那么需要升级版本大于39版本的谷歌浏览器

2. 问题:Navigation可能联想不到方法

解决方法:主要是对象首写字母没有大写而导致的

3.报错 Unexpected error launching Internet Explorer. Protected Mode settings are not the same for all zones. Enable Protected Mode must be set to the same value (enabled or disabled) for all zones. (WARNING: The server did not provide any stacktrace information)

解决方法:public static void StratIe(){         System.setProperty("webdriver.ie.driver", "files/IEDriver.exe");         DesiredCapabilities dcb = DesiredCapabilities.internetExplorer();         //关闭保护模式         dcb.setCapability("InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS",true);         dcb.setCapability("ignoreProtectedModeSettings", true);         WebDriver driver = new InternetExplorerDriver(dcb);

 

4.报错

Exception in thread "main" org.openqa.selenium.remote.SessionNotFoundException: Unexpected error launching Internet Explorer. Browser zoom level was set to 119%. It should be set to 100% (WARNING: The server did not provide any stacktrace information)

由于浏览器比例问题导致webDriver启动IE失败 现像:IE能启动但时提示“This is the initial start page for the WebDriver server.”

解决:将IE浏览器缩放比例设置成100%。之后再运行就成功了。

 

 

JavaScript warning: resource://addoninstaller/log4moz.js, line 494: mutating the [[Prototype]] of an object will cause your code to run very slowly; instead create the object with the correct initial [[Prototype]] value using Object.create

转载于:https://www.cnblogs.com/whiue/p/4657421.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值