1.使用命令行启动selenium

  下载selenium jar包  http://selenium-release.storage.googleapis.com/index.html

  此处下载的是selenium-server-standalone-3.13.0.jar

  java -jar selenium-server-standalone-3.13.0.jar

2. 执行java脚本

import org.apache.commons.io.FileUtils;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.TestNG;
import org.testng.annotations.Test; import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.util.concurrent.TimeUnit; public class errrotTest {
@Test
public void chrome() throws IOException {
DesiredCapabilities capabilities=new DesiredCapabilities();
ChromeOptions chromeOptions=new ChromeOptions();
//chromeOptions.addArguments("headless");
//chromeOptions.addArguments("window-size=400,1024");
//chromeOptions.addArguments("user-agent=\"Mozilla/5.0 (Linux; Android 4.4.2; Nexus 4 Build/KOT49H) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36\"");
capabilities.setCapability(ChromeOptions.CAPABILITY, chromeOptions); RemoteWebDriver driver=new RemoteWebDriver(new URL("http://127.0.0.1:5555/wd/hub"), capabilities);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.get("http://www.baidu.com");
FileUtils.copyFile(driver.getScreenshotAs(OutputType.FILE), new File("1.png"));
}
}

3. 使用tcpdump查看报错信息

  注意:使用tcpdump生成是二进制文件

sudo tcpdump -i any port 4444 -w tcpdump.log

4. 使用em-proxy查看报错信息

gem安装中会出现一些权限问题,需要用sudo安装。为了操作方便,以后要将ruby卸载,使用普通用户安装。

gem install em-proxy

em-proxy -l 5555 -r 127.0.0.1:4444 -v

5. 脚本中没有写Chrome driver路径,脚本依然可以启动chrome浏览器,是因为path中已经添加chromedriver

selenium除错的更多相关文章

  1. Python爬虫小白入门(四)PhatomJS+Selenium第一篇

    一.前言 在上一篇博文中,我们的爬虫面临着一个问题,在爬取Unsplash网站的时候,由于网站是下拉刷新,并没有分页.所以不能够通过页码获取页面的url来分别发送网络请求.我也尝试了其他方式,比如下拉 ...

  2. Selenium的PO模式(Page Object Model)[python版]

     Page Object Model 简称POM  普通的测试用例代码: .... #测试用例 def test_login_mail(self): driver = self.driver driv ...

  3. selenium元素定位篇

    Selenium webdriver是完全模拟用户在对浏览器进行操作,所有用户都是在页面进行的单击.双击.输入.滚动等操作,而webdriver也是一样,所以需要我们指定元素让webdriver进行单 ...

  4. selenium自动化基础知识

    什么是自动化测试? 自动化测试分为:功能自动化和性能自动化 功能自动化即使用计算机通过编码的方式来替代手工测试,完成一些重复性比较高的测试,解放测试人员的测试压力.同时,如果系统有不份模块更改后,只要 ...

  5. 幼儿园的 selenium

    from selenium import webdriver     *固定开头     b=webdriver.Firefox()              *打开火狐浏览器    browser. ...

  6. 使用selenium编写脚本常见问题(一)

    前提:我用selenium IDE录制脚本,我用java写的脚本,如果大家想看的清楚明白推荐java/Junit4/Webdriver 我用的是java/TestNG/remote control 1 ...

  7. 关于selenium RC的脚本开发

    第一.需要录制脚本,找个我也不说了.就是在firefox下下载一个selenium-IDE并且安装. 第二.在工具里找到selenium-IDE点击运行. 第三.默认是红色按钮点击状态的,接下来随便你 ...

  8. 基于python的selenium自动化测试环境安装

    1. Python2安装 官方网站:https://www.python.org/downloads/ (python3或新版本已经默认集成了pip包和path,安装的时候打勾就行,可以直接跳过下面第 ...

  9. Selenium+python 配置

    1. 安装python, www.python.org. 下载最新的python,应该是32位的.注意配置环境变量. 2. 安装PIP(pip是一个以Python计算机程序语言写成的软件包管理系统). ...

随机推荐

  1. DevExpress XtraScheduler日程管理控件应用实例(1)-- 基本使用

    在一些应用场景中,我们可能需要记录某一天,某个时段的日程安排,那么这个时候就需要引入了 DevExpress 的日程控件XtraScheduler 了,这个控件功能非常强大,提供了很好的界面展现方式, ...

  2. css 和 UI 框架 ---------- vue 待续

    vue 框架组件集合 radon-UI: 他人评价 --  一个帮助你快速开发产品的Vue组件库,简洁好用,效率高,让你摆脱各种定制化的烦恼. 个人感觉 --   组件简洁,  功能全面,  文档清晰 ...

  3. TP使用易错知识点

    1.  redirect(U('Index/index'));     //redirect函数跳转要使用U方法,不适用U方法会跳转地址出错. 2.  $this->success('新增成功' ...

  4. About RFC

    RFC说明 Request For Comments (RFC),是一系列以编号排定的文件,几乎所有的因特网标准都收录在RFC文件之中,如果你想成为网络方面的专家,那么RFC无疑是最重要也是最经常需要 ...

  5. react 部分ES6写法

    react+react-router+antd 栗子:https://github.com/Aquarius1993/reactApp 模块: 1. 引入模块 import React from 'r ...

  6. Texas Instruments matrix-gui-2.0 hacking -- menubar.php

    <?php /* * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/ * * * Redistrib ...

  7. 小程序api请求层封装(Loading全局配置)

    前言 小程序开发,没有vue中的axios那么好使,请求层的封装需要自己来搞. 当然请求层的配置少不了loading,这里索性也就将loading做一个配置,避免以后重复造轮子 请求封装 小程序中有封 ...

  8. 20分钟打造你的Bootstrap站点

    来源:http://www.w3cplus.com/css/twitter-bootstrap-tutorial.html 特别声明:此篇文章由白牙根据Leon Revill的英文文章原名<Tw ...

  9. Ubuntu 速配指南:开启3D桌面特效

     http://www.lupaworld.com/article-205494-1.html 安装compizconfig-settings-manager(以下简称ccsm) 在终端里输入:sud ...

  10. Struts2访问ServletAPI的三种方式

    web应用中需要访问的ServletAPI,通常只有HttpServletRequest,HttpSession,ServletContext三个,这三个接口分别代表jsp内置对象中的request, ...