LanHao 发布的文章

转载自 https://www.cnblogs.com/goldenRazor/p/4979042.html

原作者:GoldenRazor

新建一个

WebDriver driver = new FirefoxDriver();

Firefox目录变更

System.setProperty("webdriver.firefox.bin","D:/Program Files/Mozilla Firefox/firefox.exe");

开URL

Driver.get(url);
Driver.Navigation.to(url);

设置firefox

1.新建一个 firefox -p 一般默认在:

C:\Users\Administrator\AppData\Roaming\Mozilla\Firefox\Profiles

2.在代码里引用这个profile

File F = new File("C:\\Users\\Administrator\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\9xhxx9r7.Selenium");
FirefoxProfile profile = new FirefoxProfile(file);
WebDriver driver = new FirefoxDriver(profile);

加载插件

复制代码

File file = new File("files/firebug-2.0.7-fx.xpi");
FirefoxProfile profile = new FirefoxProfile();
try{
    profile.addExtension(file);
}catch(Exception e){
   e.printStackTrace();
}

WebDriver driver = new FirefoxDriver(profile);

复制代码

通过about:config可以看到firefox的设置,可以通过代码改变, 有些设置直接可以通过firefox profile来设置

复制代码

        //设置代理参数
profile.setPreference("network.proxy.type", 1);
profile.setPreference("network.proxy.http", proxyIp);
profile.setPreference("network.proxy.http_port", proxyPort);
        
        //设置默认下载路径
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.download.dir", "D:\\");

复制代码

capabilities的设置

DesiredCapabilities capabilities = new DesiredCapabilities(); 

DesiredCapabilities capabilities = DesiredCapabilities.firefox();
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
driver = new FirefoxDriver(capabilities);

这个capabilities是启动一个session必备的,是对所有driver都可以设置的,而firefoxprofile只有firefox只适用firefox

Driver的timeout设置

复制代码

页面加载timeout
driver.manage().timeouts().pageLoadTimeout(pageLoadTimeout, TimeUnit.SECONDS);
找对象的timeout,动态找 driver.manage().timeouts().implicitlyWait(waitTimeout, TimeUnit.SECONDS);
脚本执行的timeout driver.manage().timeouts().setScriptTimeout(scriptTimeout, TimeUnit.SECONDS);

复制代码

如果想在页面没有加载完成的情况下就点击或者识别元素,用finally

 FirefoxDriver在selenium3的时候已经被弃用了,FirefoxDriver原理是用firefox的add-on来实现对浏览器的控制。

更新后目前用的是geckodriver.exe,是通过geckodriver把W3 WebDriver wire protocol翻译成Marionette可以识别的协议接口,最终通过Marionette来实现对浏览器的控制。

最近闲鱼入了一个

Verizon美版pixel,Android pie系统

解锁Oem 出现一些很麻烦的问题

根据XDA 的方法,并刷入dePixel8(虽然显示失败,但是可以解)

(from XDA↓)

  1. Remove Google account and any kind of screen lock (fingerprint, PIN, pattern, etc.) from your device.移除Google账户,还有屏幕锁(指纹,PIN,图形等)
  2. Eject sim card from your device. 从设备中弹出SIM电话卡
  3. Reset your device. In setup wizard, skip everything, don’t connect to WiFi, don’t add fingerprint or any kind of screen lock.重置你的手机,在开始引导中,跳过所有,不要连接WIFI,不要加入指纹或者任何形式的屏幕锁
  4. Go to Developer Options and enable USB debugging.在开发者选项中打开USB调试
  5. Connect your phone to PC.将手机连接到电脑
  6. Open CMD in adb directory and type: adb shell pm uninstall --user 0 com.android.phone 打开CMD,adb中输入上面的代码
  7. Restart your device.重启手机
  8. Connect to WiFi, open Chrome and go to google.com (or any website really).连接wifi,打开浏览器访问一个网站。
  9. Go to Developer Options and enable OEM unlocking.去开发者模式中打开OEM锁
  10. Reboot into bootloader and via CMD run: fastboot oem unlock OR fastboot flashing unlock重启进入BOOTLOADER 在CMD中解锁

烤 羊肉串

羊肉 腌制,

烤箱210度上下 预热10分钟

烤15分钟,取出,上孜然,烧烤酱

继续烤5分钟

OK。

蛋挞

200度上下  预热10分钟

烤15-20分钟 取出

下载python 最新 3.7.0

https://www.python.org/downloads/

记住勾选加入系统变量

cd到python安装目录下的Scripts文件夹下的easy_install.exe文件。

在cmd里面输入pip指令,看到则为成功

然后升级pip到18

pip install selenium

pip install --upgrade robotframework-seleniumlibrary
pip install robotframework

pip install -U -r https://raw.githubusercontent.com/HelioGuilherme66/RIDE/v1.7.2/requirements.txt
pip install -U https://github.com/HelioGuilherme66/RIDE/archive/v1.7.2.tar.gz
chromedriver版本 支持的Chrome版本
v2.41 v67-69

可能漏了一些…我装的时候好像还装了几个额外的…不过忘记了。。。

有一些种子,下载的时候根本没有速度!所以离线下载成为一个很棒的帮手。

最近我发现一个超棒的种子离线下载网站(SEEDR.CC)!关键是免费!

初始分配给用户就有2G!很多了!

根据我的测试,迅雷找不到资源的,这个网站可以!而且速度很快!

如果你使用我的链接注册,你和我都会同时增加500MB空间,

(不过限制每个用户只能邀请四个人,所以!抓紧机会!)

点击下面的连接,进行注册!

https://www.seedr.cc/?r=1287934

阅读剩余部分