


npm uninstall -g protractor && cnpm install -g protractor && protractor --version
复制 驱动等到指定位置
&& webdriver-manager update && webdriver-manager start
protractor --version
Version 5.2.0
卸载的时候区分大小写
npm uninstall -g protractor
webdriver-manager 工具和之前下载好的包都没了
C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\node_modules\_webdriver-manager@12.0.6@webdriver-manager\selenium
cnpm install -g protractor
完美不报错 , 也没有警告
C:\Users\pc>cnpm install -g protractor
Downloading protractor to C:\Users\pc\AppData\Roaming\npm\node_modules\protractor_tmp
Copying C:\Users\pc\AppData\Roaming\npm\node_modules\protractor_tmp\_protractor@5.2.0@protractor to C:\Users\pc\AppData\Roaming\npm\node_modules\protractor
Installing protractor's dependencies to C:\Users\pc\AppData\Roaming\npm\node_modules\protractor/node_modules
[1/15] q@1.4.1 installed at node_modules\_q@1.4.1@q
[2/15] jasminewd2@^2.1.0 installed at node_modules\_jasminewd2@2.2.0@jasminewd2
[3/15] @types/q@^0.0.32 installed at node_modules\_@types_q@0.0.32@@types\q
[4/15] optimist@~0.6.0 installed at node_modules\_optimist@0.6.1@optimist
[5/15] @types/node@^6.0.46 installed at node_modules\_@types_node@6.0.92@@types\node
[6/15] chalk@^1.1.3 installed at node_modules\_chalk@1.1.3@chalk
[7/15] blocking-proxy@0.0.5 installed at node_modules\_blocking-proxy@0.0.5@blocking-proxy
[8/15] @types/selenium-webdriver@~2.53.39 installed at node_modules\_@types_selenium-webdriver@2.53.43@@types\selenium-webdriver
[9/15] jasmine@^2.5.3 installed at node_modules\_jasmine@2.8.0@jasmine
[10/15] glob@^7.0.3 installed at node_modules\_glob@7.1.2@glob
[11/15] saucelabs@~1.3.0 installed at node_modules\_saucelabs@1.3.0@saucelabs
[12/15] source-map-support@~0.4.0 installed at node_modules\_source-map-support@0.4.18@source-map-support
[13/15] webdriver-manager@^12.0.6 installed at node_modules\_webdriver-manager@12.0.6@webdriver-manager
[14/15] selenium-webdriver@3.6.0 installed at node_modules\_selenium-webdriver@3.6.0@selenium-webdriver
[15/15] webdriver-js-extender@^1.0.0 installed at node_modules\_webdriver-js-extender@1.0.0@webdriver-js-extender
Recently updated (since 2017-11-27): 3 packages (detail see file C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\node_modules\.recently_updates.txt)
2017-12-02
→ webdriver-manager@12.0.6 › request@2.83.0 › har-validator@5.0.3 › ajv@^5.1.0(5.5.1) (20:48:13)
2017-12-01
→ webdriver-manager@12.0.6 › request@2.83.0 › http-signature@1.2.0 › jsprim@1.4.1 › verror@1.10.0 › extsprintf@^1.2.0(1.4.0) (05:26:44)
2017-11-30
→ webdriver-manager@12.0.6 › del@2.2.2 › is-path-in-cwd@1.0.0 › is-path-inside@^1.0.0(1.0.1) (18:34:52)
All packages installed (137 packages installed from npm registry, used 27s, speed 210.86kB/s, json 127(254.64kB), tarball 5.29MB)
[protractor@5.2.0] link C:\Users\pc\AppData\Roaming\npm\protractor@ -> C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\bin\protractor
[protractor@5.2.0] link C:\Users\pc\AppData\Roaming\npm\webdriver-manager@ -> C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\bin\webdriver-manager
29
1
C:\Users\pc>cnpm install -g protractor
2
Downloading protractor to C:\Users\pc\AppData\Roaming\npm\node_modules\protractor_tmp
3
Copying C:\Users\pc\AppData\Roaming\npm\node_modules\protractor_tmp\_protractor@5.2.0@protractor to C:\Users\pc\AppData\Roaming\npm\node_modules\protractor
4
Installing protractor's dependencies to C:\Users\pc\AppData\Roaming\npm\node_modules\protractor/node_modules
5
[1/15] q@1.4.1 installed at node_modules\_q@1.4.1@q
6
[2/15] jasminewd2@^2.1.0 installed at node_modules\_jasminewd2@2.2.0@jasminewd2
7
[3/15] @types/q@^0.0.32 installed at node_modules\_@types_q@0.0.32@@types\q
8
[4/15] optimist@~0.6.0 installed at node_modules\_optimist@0.6.1@optimist
9
[5/15] @types/node@^6.0.46 installed at node_modules\_@types_node@6.0.92@@types\node
10
[6/15] chalk@^1.1.3 installed at node_modules\_chalk@1.1.3@chalk
11
[7/15] blocking-proxy@0.0.5 installed at node_modules\_blocking-proxy@0.0.5@blocking-proxy
12
[8/15] @types/selenium-webdriver@~2.53.39 installed at node_modules\_@types_selenium-webdriver@2.53.43@@types\selenium-webdriver
13
[9/15] jasmine@^2.5.3 installed at node_modules\_jasmine@2.8.0@jasmine
14
[10/15] glob@^7.0.3 installed at node_modules\_glob@7.1.2@glob
15
[11/15] saucelabs@~1.3.0 installed at node_modules\_saucelabs@1.3.0@saucelabs
16
[12/15] source-map-support@~0.4.0 installed at node_modules\_source-map-support@0.4.18@source-map-support
17
[13/15] webdriver-manager@^12.0.6 installed at node_modules\_webdriver-manager@12.0.6@webdriver-manager
18
[14/15] selenium-webdriver@3.6.0 installed at node_modules\_selenium-webdriver@3.6.0@selenium-webdriver
19
[15/15] webdriver-js-extender@^1.0.0 installed at node_modules\_webdriver-js-extender@1.0.0@webdriver-js-extender
20
Recently updated (since 2017-11-27): 3 packages (detail see file C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\node_modules\.recently_updates.txt)
21
2017-12-02
22
→ webdriver-manager@12.0.6 › request@2.83.0 › har-validator@5.0.3 › ajv@^5.1.0(5.5.1) (20:48:13)
23
2017-12-01
24
→ webdriver-manager@12.0.6 › request@2.83.0 › http-signature@1.2.0 › jsprim@1.4.1 › verror@1.10.0 › extsprintf@^1.2.0(1.4.0) (05:26:44)
25
2017-11-30
26
→ webdriver-manager@12.0.6 › del@2.2.2 › is-path-in-cwd@1.0.0 › is-path-inside@^1.0.0(1.0.1) (18:34:52)
27
All packages installed (137 packages installed from npm registry, used 27s, speed 210.86kB/s, json 127(254.64kB), tarball 5.29MB)
28
[protractor@5.2.0] link C:\Users\pc\AppData\Roaming\npm\protractor@ -> C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\bin\protractor
29
[protractor@5.2.0] link C:\Users\pc\AppData\Roaming\npm\webdriver-manager@ -> C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\bin\webdriver-manager
npm uninstall -g webdriver-manager
没得卸载 , 因为它不是单独的工具
C:\Users\pc>npm uninstall -g webdriver-manager
up to date in 0.035s
重新安装
C:\Users\pc>webdriver-manager update
[09:44:21] I/update - geckodriver: file exists C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\node_modules\_webdriver-manager@12.0.6@webdriver-manager\selenium\geckodriver-v0.19.1.zip
[09:44:21] I/update - geckodriver: unzipping geckodriver-v0.19.1.zip
[09:44:21] I/update - geckodriver: geckodriver-v0.19.1.exe up to date
events.js:183
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at _errnoException (util.js:1024:11)
at TLSWrap.onread (net.js:615:25)
11
1
C:\Users\pc>webdriver-manager update
2
[09:44:21] I/update - geckodriver: file exists C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\node_modules\_webdriver-manager@12.0.6@webdriver-manager\selenium\geckodriver-v0.19.1.zip
3
[09:44:21] I/update - geckodriver: unzipping geckodriver-v0.19.1.zip
4
[09:44:21] I/update - geckodriver: geckodriver-v0.19.1.exe up to date
5
events.js:183
6
throw er; // Unhandled 'error' event
7
^
8
9
Error: read ECONNRESET
10
at _errnoException (util.js:1024:11)
11
at TLSWrap.onread (net.js:615:25)
类似的报错
蓝灯
设置代理
全局
下载都成功了
我看文件里面 , 解压好了
但是一个卡在这里

要终止再来一次吗
还是一直挂机 ?
应该是之前 Protractor 安装出错了
因为文件都下载回来了
无效 npm uninstall
set http_proxy=http:localhost:56138
127.0.0.1
端口
56138
分析一下 , JavaScript 里 , 是不是解压的工具坏了 , 是不是要重新安装 ?
webdriver-manager start
webdriver-manager update
果然每天早点都要更新一次 , start 脚本里面好像有在检查最新版
webdriver-manager update && webdriver-manager start
D:\>webdriver-manager update --standalone
[09:17:01] I/update - geckodriver: file exists C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\geckodriver-v0.19.1.zip
[09:17:01] I/update - geckodriver: unzipping geckodriver-v0.19.1.zip
[09:17:01] I/update - geckodriver: geckodriver-v0.19.1.exe up to date
events.js:183
throw er; // Unhandled 'error' event
^
Error: connect ETIMEDOUT 172.217.24.16:443
at Object._errnoException (util.js:1024:11)
at _exceptionWithHostPort (util.js:1046:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
protractor --version
Version 5.2.0
C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium
把文件移动当更下一层 , 然后让它重新下载 , 不是解压已有的
webdriver-manager update --standalone
又抽筋了 , 无法启动

是操作系统做了什么吗
在这之前系统升级了一下
我的博客
http://www.cnblogs.com/xiaoCong2016/p/7440741.html
只要 webdriver-manager update 成功后
webdriver-manager start 不会无效的情况 :{
update 成功后马上 start
把全部cmd都关闭再开一个cmd
在 git + cmd
最后重启电脑后试一下start 会不会跪了
}
我创建的Protractor 自动化群
2017-12-01 就只有我一个人
594926460
之前网络不好 , 连驱动都需要下载很多次才成功
有时候挂机一个晚上驱动也不行 , 最终会报错 , 说网络超时
现在可以了
果然是网络的问题, 有时候会抽筋
5
1
之前网络不好 , 连驱动都需要下载很多次才成功
2
有时候挂机一个晚上驱动也不行 , 最终会报错 , 说网络超时
3
4
现在可以了
5
果然是网络的问题, 有时候会抽筋
# 安装驱动
C:\Users\pc>webdriver-manager update
[09:31:56] I/update - chromedriver: file exists C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.33.zip
[09:31:56] I/update - chromedriver: unzipping chromedriver_2.33.zip
[09:31:56] I/update - chromedriver: chromedriver_2.33.exe up to date
[09:32:22] E/downloader - Connection timeout downloading: https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-win64.zip. Default timeout is 4 minutes.
[09:32:22] I/update - geckodriver: file exists C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\geckodriver-v0.19.1.zip
[09:32:22] I/update - geckodriver: unzipping geckodriver-v0.19.1.zip
(node:27460) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Invalid or unsupported zip format. No END header found
(node:27460) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
# 运行
C:\Users\pc>webdriver-manager start
[09:35:52] I/start - java -Dwebdriver.chrome.driver=C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.33.exe -jar C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.8.0.jar -port 4444
[09:35:52] I/start - seleniumProcess.pid: 17572
09:35:52.582 INFO - Selenium build info: version: '3.8.0', revision: '924c4067df'
09:35:52.583 INFO - Launching a standalone Selenium Server
2017-12-01 09:35:52.670:INFO::main: Logging initialized @390ms to org.seleniumhq.jetty9.util.log.StdErrLog
09:35:52.696 INFO - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
09:35:52.705 INFO - Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
09:35:52.707 INFO - Using `new EdgeOptions()` is preferred to `DesiredCapabilities.edge()`
09:35:52.707 INFO - Driver class not found: com.opera.core.systems.OperaDriver
09:35:52.707 INFO - Using `new OperaOptions()` is preferred to `DesiredCapabilities.operaBlink()`
09:35:52.710 INFO - Using `new SafariOptions()` is preferred to `DesiredCapabilities.safari()`
09:35:52.712 INFO - Driver class not found: org.openqa.selenium.phantomjs.PhantomJSDriver
09:35:52.741 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities {browserName: safari, platform: MAC, version: } does not match the current platform WIN10
09:35:52.772 INFO - Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
09:35:52.773 INFO - Using `new EdgeOptions()` is preferred to `DesiredCapabilities.edge()`
09:35:52.777 INFO - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
09:35:52.781 INFO - Using `new OperaOptions()` is preferred to `DesiredCapabilities.operaBlink()`
09:35:52.783 INFO - Using `new SafariOptions()` is preferred to `DesiredCapabilities.safari()`
09:35:52.791 INFO - Using the passthrough mode handler
2017-12-01 09:35:52.809:INFO:osjs.Server:main: jetty-9.4.7.v20170914
2017-12-01 09:35:52.825:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.ServletContextHandler@2db7a79b{/,null,STARTING} has uncovered http methods for path: /
2017-12-01 09:35:52.829:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@2db7a79b{/,null,AVAILABLE}2017-12-01 09:35:52.862:INFO:osjs.AbstractConnector:main: Started ServerConnector@652d2fa2{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-12-01 09:35:52.868:INFO:osjs.Server:main: Started @588ms
09:35:52.871 INFO - Selenium Server is up and running
39
1
# 安装驱动
2
C:\Users\pc>webdriver-manager update
3
[09:31:56] I/update - chromedriver: file exists C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.33.zip
4
[09:31:56] I/update - chromedriver: unzipping chromedriver_2.33.zip
5
[09:31:56] I/update - chromedriver: chromedriver_2.33.exe up to date
6
[09:32:22] E/downloader - Connection timeout downloading: https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-win64.zip. Default timeout is 4 minutes.
7
[09:32:22] I/update - geckodriver: file exists C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\geckodriver-v0.19.1.zip
8
[09:32:22] I/update - geckodriver: unzipping geckodriver-v0.19.1.zip
9
(node:27460) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Invalid or unsupported zip format. No END header found
10
(node:27460) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
11
12
# 运行
13
C:\Users\pc>webdriver-manager start
14
[09:35:52] I/start - java -Dwebdriver.chrome.driver=C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.33.exe -jar C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.8.0.jar -port 4444
15
[09:35:52] I/start - seleniumProcess.pid: 17572
16
09:35:52.582 INFO - Selenium build info: version: '3.8.0', revision: '924c4067df'
17
09:35:52.583 INFO - Launching a standalone Selenium Server
18
2017-12-01 09:35:52.670:INFO::main: Logging initialized @390ms to org.seleniumhq.jetty9.util.log.StdErrLog
19
09:35:52.696 INFO - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
20
09:35:52.705 INFO - Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
21
09:35:52.707 INFO - Using `new EdgeOptions()` is preferred to `DesiredCapabilities.edge()`
22
09:35:52.707 INFO - Driver class not found: com.opera.core.systems.OperaDriver
23
09:35:52.707 INFO - Using `new OperaOptions()` is preferred to `DesiredCapabilities.operaBlink()`
24
09:35:52.710 INFO - Using `new SafariOptions()` is preferred to `DesiredCapabilities.safari()`
25
09:35:52.712 INFO - Driver class not found: org.openqa.selenium.phantomjs.PhantomJSDriver
26
09:35:52.741 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:
27
registration capabilities Capabilities {browserName: safari, platform: MAC, version: } does not match the current platform WIN10
28
09:35:52.772 INFO - Using `new ChromeOptions()` is preferred to `DesiredCapabilities.chrome()`
29
09:35:52.773 INFO - Using `new EdgeOptions()` is preferred to `DesiredCapabilities.edge()`
30
09:35:52.777 INFO - Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`
31
09:35:52.781 INFO - Using `new OperaOptions()` is preferred to `DesiredCapabilities.operaBlink()`
32
09:35:52.783 INFO - Using `new SafariOptions()` is preferred to `DesiredCapabilities.safari()`
33
09:35:52.791 INFO - Using the passthrough mode handler
34
2017-12-01 09:35:52.809:INFO:osjs.Server:main: jetty-9.4.7.v20170914
35
2017-12-01 09:35:52.825:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.ServletContextHandler@2db7a79b{/,null,STARTING} has uncovered http methods for path: /
36
2017-12-01 09:35:52.829:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@2db7a79b{/,null,AVAILABLE}2017-12-01 09:35:52.862:INFO:osjs.AbstractConnector:main: Started ServerConnector@652d2fa2{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
37
2017-12-01 09:35:52.868:INFO:osjs.Server:main: Started @588ms
38
09:35:52.871 INFO - Selenium Server is up and running
39

todo
Protractor 提供的测试页面 , 计算器
http://juliemr.github.io/protractor-demo/
控制台正常 , 只是 有个图标没有加载到 , 没关系
面向页面的试试
http://blog.csdn.net/github_39212680/article/details/73433870
写得很详细
http://www.protractortest.org/#/
文档
http://www.protractortest.org/#/typescript
例子
https://github.com/angular/protractor/tree/5.2.0/exampleTypescript
简介
官网
http://www.protractortest.org/
github
https://github.com/angular/protractor
官网稍慢 , 但能打得开 Angular CLI 内置 官方推荐
可用于 AngularJS 和 Angular 的 端到端 web 自动化测试
可以根据 模型 和 bind 来找元素很方便
E2E test framework for Angular apps
Protractor is an end-to-end test framework for Angular and AngularJS applications.
Protractor is a Node.js program built on top of WebDriverJS.
安装
在国内很可能安装失败 , 所以我建议用阿里提供的 cnpm 工具
npm install -g cnpm
后面的操作 , 用到 npm install 的命令都建议用 cnpm install 替代 , 就是最前面加个 c 字母
npm install -g protractor
会自动安装两个工具:protractor 和 webdriver-manager
看是否安装成功,成功的话 : {
先确认 protractor , 命令行里执行 :
protractor
**you must either specify a configuration file or at least 3 options. See below for the options:
Usage: protractor [configFile] [options]
configFile defaults to protractor.conf.js
The [options] object will override values from the config file.
See the reference config for a full list of options.
Options:
--help Print Protractor help menu
( 以下省略 )
其次确认 webdriver-manager , 命令行里执行 :
webdriver-manager
Usage: webdriver-manager <command> [options]
Commands:
clean removes all downloaded driver files from the out_dir
start start up the selenium server
shutdown shut down the selenium server
status list the current available drivers
update install or update selected binaries
version get the current version
( 以下省略 )
}
更新浏览器驱动
webdriver-manager update
确保本地安装好的谷歌浏览器的版本 是 59 以上
我的当前版本 ( 58.0 ) 太旧 , 要更新 . 不然在运行脚本的时候会提示 Chrome version must be >= 59.0.3071.0 ,
也就是建议升级谷歌浏览器到 59.0 以上
之前的 :

查看谷歌浏览器的版本 , 在URL地址栏输入
chrome://settings/help
在浏览器里自动更新就行 , 不行的话再百度安装包
更新好后 :
版本 : 60.0.3112.113(正式版本) (64 位)
执行测试代码之前要开启服务
webdriver-manager start
学习资料
api 文档
http://www.protractortest.org/#/api
推酷上搜不到
主要是官网
http://www.protractortest.org/
快速入门
http://www.protractortest.org/#/tutorial
总的教程目录
http://www.protractortest.org/#/toc
而且可以用 TypeScript 写
还有调试 自动化测试代码 的技巧
对应的代码
https://github.com/angular/protractor/tree/5.1.2/exampleTypescript
第三方文章
端对端的自动化测试
自动化端对端测试-Protrator Tutorial
https://my.oschina.net/u/658505/blog/665158
http://juliemr.github.io/protractor-demo/
实践 /尝试 自己试一下
国人翻译的
http://www.cnblogs.com/haogj/p/4815673.html
被测试的网站 http://juliemr.github.io/protractor-demo/ , 官方搭建的
安装成功 : 步骤
安装 Protractor 软件
更新 webdriver-manager
在任意位置开服务 , 不是 serve 或者 server
webdriver-manager start
到当前目录
cd /d G:\autoTest\Protractor\First
protractor + 配置文件.js
protractor config.js
config.js 里面配置里要执行 example_spec.js 测试用例文件 , 可以配置多个
脚本启动正常 :
G:\autoTest\Protractor\First>protractor config.js
[10:47:41] I/launcher - Running 1 instances of WebDriver
[10:47:41] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
Started
4
1
G:\autoTest\Protractor\First>protractor config.js
2
[10:47:41] I/launcher - Running 1 instances of WebDriver
3
[10:47:41] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
4
Started
出现Chrome浏览器
脚本自动运行
过段时间自动退出 , 控制台显示报错 , 这个没事
清理 cmd
cls
知识点
beforeEach
每个方法 ( 测试用例 ) 执行前都会执行这个方法 , 很常用的场景 :
beforeEach( function() {
browser.get('http://juliemr.github.io/protractor-demo/');
}
);
每次都打开网址
it 是什么
为什么有两个嵌套的 描述 ?
问题
webdriver-manager update 无法安装
PS C:\Windows\system32> webdriver-manager update
events.js:183
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at _errnoException (util.js:1024:11)
at TLSWrap.onread (net.js:615:25)
C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium
文件夹创建成功
pc>webdriver-manager update
[20:55:45] I/file_manager - creating folder C:\Users\pc\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium
events.js:183
throw er; // Unhandled 'error' event
^
Error: connect ETIMEDOUT 172.217.27.144:443
at Object._errnoException (util.js:1024:11)
at _exceptionWithHostPort (util.js:1046:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1182:14)
现象 :
{
不安装的话启动服务的时候会提示
根据提示执行命令
webdriver-manager update --standalone
之前是报错
然后是
}
npm uninstall -g protractor
重装
npm install -g protractor
因为需要创建文件夹
需要我用管理员权限打开cmd吗
111
开了蓝灯 , 一直重试
能单独下载到
webdriver-manager start 无法启动服务 , 之前可以
之前可以的
E:\autoTest\Protractor\Protractor-source>webdriver-manager start
[15:56:31] I/start - java -Dwebdriver.chrome.driver=C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.32.exe -jar C:\Users\zhangqiang\AppData\Roaming\np
m\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.5.3.jar -port 4444
[15:56:31] I/start - seleniumProcess.pid: 17148
Error: Unable to access jarfile C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.5.3.jar
[15:56:32] I/start - Selenium Standalone has exited with code 1
6
1
E:\autoTest\Protractor\Protractor-source>webdriver-manager start
2
[15:56:31] I/start - java -Dwebdriver.chrome.driver=C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.32.exe -jar C:\Users\zhangqiang\AppData\Roaming\np
3
m\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.5.3.jar -port 4444
4
[15:56:31] I/start - seleniumProcess.pid: 17148
5
Error: Unable to access jarfile C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.5.3.jar
6
[15:56:32] I/start - Selenium Standalone has exited with code 1
解决方法
重装一下 , webdriver-manager update
因为环境坏了 , 或者不是最新版
服务正常了 : ( 最下面一行没有结束 , 光标会一直闪烁 ) 提示 Selenium Server is up and running
C:\Users\zhangqiang>webdriver-manager start
[10:26:31] I/start - java -Dwebdriver.chrome.driver=C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\_webdriver-manager@12.0.6@webdriver-manager\selenium\chromedriver_2.33.exe -Dwebdriver.gecko.driver=C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\_webdriver-manager@12.0.6@webdriver-manager\selenium\geckodriver-v0.19.0.exe -jar C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\_webdriver-manager@12.0.6@webdriver-manager\selenium\selenium-server-standalone-3.6.0.jar -port 4444
[10:26:31] I/start - seleniumProcess.pid: 82572
10:26:34.618 INFO - Selenium build info: version: '3.6.0', revision: '6fbf3ec767'
10:26:34.632 INFO - Launching a standalone Selenium Server
2017-10-23 10:26:34.765:INFO::main: Logging initialized @2565ms to org.seleniumhq.jetty9.util.log.StdErrLog
10:26:35.042 INFO - Driver class not found: com.opera.core.systems.OperaDriver
10:26:35.396 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform WIN8_1
10:26:35.665 INFO - Using the passthrough mode handler
2017-10-23 10:26:35.815:INFO:osjs.Server:main: jetty-9.4.5.v20170502
2017-10-23 10:26:35.993:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.ServletContextHandler@5a8e6209{/,null,STARTING} has uncovered http methods for path: /
2017-10-23 10:26:36.048:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@5a8e6209{/,null,AVAILABLE}
2017-10-23 10:26:36.348:INFO:osjs.AbstractConnector:main: Started ServerConnector@614ddd49{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-10-23 10:26:36.354:INFO:osjs.Server:main: Started @4154ms
10:26:36.361 INFO - Selenium Server is up and running
x
1
C:\Users\zhangqiang>webdriver-manager start
2
[10:26:31] I/start - java -Dwebdriver.chrome.driver=C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\_webdriver-manager@12.0.6@webdriver-manager\selenium\chromedriver_2.33.exe -Dwebdriver.gecko.driver=C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\_webdriver-manager@12.0.6@webdriver-manager\selenium\geckodriver-v0.19.0.exe -jar C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\_webdriver-manager@12.0.6@webdriver-manager\selenium\selenium-server-standalone-3.6.0.jar -port 4444
3
[10:26:31] I/start - seleniumProcess.pid: 82572
4
10:26:34.618 INFO - Selenium build info: version: '3.6.0', revision: '6fbf3ec767'
5
10:26:34.632 INFO - Launching a standalone Selenium Server
6
2017-10-23 10:26:34.765:INFO::main: Logging initialized @2565ms to org.seleniumhq.jetty9.util.log.StdErrLog
7
10:26:35.042 INFO - Driver class not found: com.opera.core.systems.OperaDriver
8
10:26:35.396 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:
9
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform WIN8_1
10
10:26:35.665 INFO - Using the passthrough mode handler
11
2017-10-23 10:26:35.815:INFO:osjs.Server:main: jetty-9.4.5.v20170502
12
2017-10-23 10:26:35.993:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.ServletContextHandler@5a8e6209{/,null,STARTING} has uncovered http methods for path: /
13
2017-10-23 10:26:36.048:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@5a8e6209{/,null,AVAILABLE}
14
2017-10-23 10:26:36.348:INFO:osjs.AbstractConnector:main: Started ServerConnector@614ddd49{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
15
2017-10-23 10:26:36.354:INFO:osjs.Server:main: Started @4154ms
16
10:26:36.361 INFO - Selenium Server is up and running
17
脚本也启动正常
ReferenceError: browser is not defined
要先启动服务 webdriver-manager start
然后就正常了
备注
自动化测试代码执行期间 , 可以做别的事情 , 因为是脚本在操作浏览器
不需要在这之前手动启动浏览器 , 但Selenium 代理服务要先启动
Chrome version must be >= 59.0.3071.0
在WebStorm run 服务 , 但不行
重装一次
文件下载到
C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\_webdriver-manager@12.0.6@webdriver-manager\selenium
7个文件
下载好后
解压太慢 , 我手动解压了
再执行一次更新
仍旧是7个文件 , 没有解压的
还是不行 , 需要update
这个一直都下载失败 geckodriver-v0.18.0-win64.zip
I/update - geckodriver: unzipping geckodriver-v0.18.0.zip
(node:2200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Invalid filename
报错说文件名有问题 , 所以无法解压 . 但其实是因为 0大小 , 没下载成功 .
自己手动下载 , 然后放到对应的目录里
单击 0 大小的压缩包
成功的 , 用自动下载的
http://localhost:4444/wd/hub/static/resource/hub.html
update 包下载不下来
服务忘了了
本地的谷歌浏览器太久
Protractor 官方在GitHub的 TypeScript 依赖包安装失败
重装试试
其他的正常
run 起来试试
后面有时间再按照你的需求改UI


可以根据 模型 和 bind 来找元素很方便

protractor
**you must either specify a configuration file or at least 3 options. See below for the options:
Usage: protractor [configFile] [options]
configFile defaults to protractor.conf.js
The [options] object will override values from the config file.
See the reference config for a full list of options.
Options:
--help Print Protractor help menu
webdriver-manager
Usage: webdriver-manager <command> [options]
Commands:
clean removes all downloaded driver files from the out_dir
start start up the selenium server
shutdown shut down the selenium server
status list the current available drivers
update install or update selected binaries
version get the current version
我的当前版本 ( 58.0 ) 太旧 , 要更新 . 不然在运行脚本的时候会提示 Chrome version must be >= 59.0.3071.0 ,
也就是建议升级谷歌浏览器到 59.0 以上
之前的 :

查看谷歌浏览器的版本 , 在URL地址栏输入
chrome://settings/help
在浏览器里自动更新就行 , 不行的话再百度安装包
更新好后 :

版本 : 60.0.3112.113(正式版本) (64 位)
执行测试代码之前要开启服务
webdriver-manager start
学习资料
api 文档
http://www.protractortest.org/#/api
推酷上搜不到
主要是官网
http://www.protractortest.org/
快速入门
http://www.protractortest.org/#/tutorial
总的教程目录
http://www.protractortest.org/#/toc
而且可以用 TypeScript 写
还有调试 自动化测试代码 的技巧
对应的代码
https://github.com/angular/protractor/tree/5.1.2/exampleTypescript
第三方文章
端对端的自动化测试
自动化端对端测试-Protrator Tutorial
https://my.oschina.net/u/658505/blog/665158
http://juliemr.github.io/protractor-demo/

主要是官网
http://www.protractortest.org/
快速入门
http://www.protractortest.org/#/tutorial
总的教程目录
http://www.protractortest.org/#/toc

而且可以用 TypeScript 写
还有调试 自动化测试代码 的技巧
对应的代码
https://github.com/angular/protractor/tree/5.1.2/exampleTypescript
第三方文章
端对端的自动化测试
自动化端对端测试-Protrator Tutorial
https://my.oschina.net/u/658505/blog/665158
http://juliemr.github.io/protractor-demo/
G:\autoTest\Protractor\First>protractor config.js
[10:47:41] I/launcher - Running 1 instances of WebDriver
[10:47:41] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
Started
4
1
G:\autoTest\Protractor\First>protractor config.js
2
[10:47:41] I/launcher - Running 1 instances of WebDriver
3
[10:47:41] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
4
Started
每个方法 ( 测试用例 ) 执行前都会执行这个方法 , 很常用的场景 :
问题


根据提示执行命令
webdriver-manager update --standalone
之前是报错

然后是

}
npm uninstall -g protractor
重装
npm install -g protractor
因为需要创建文件夹
需要我用管理员权限打开cmd吗
111

webdriver-manager start 无法启动服务 , 之前可以
之前可以的
E:\autoTest\Protractor\Protractor-source>webdriver-manager start
[15:56:31] I/start - java -Dwebdriver.chrome.driver=C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.32.exe -jar C:\Users\zhangqiang\AppData\Roaming\np
m\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.5.3.jar -port 4444
[15:56:31] I/start - seleniumProcess.pid: 17148
Error: Unable to access jarfile C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.5.3.jar
[15:56:32] I/start - Selenium Standalone has exited with code 1
6
1
E:\autoTest\Protractor\Protractor-source>webdriver-manager start
2
[15:56:31] I/start - java -Dwebdriver.chrome.driver=C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\chromedriver_2.32.exe -jar C:\Users\zhangqiang\AppData\Roaming\np
3
m\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.5.3.jar -port 4444
4
[15:56:31] I/start - seleniumProcess.pid: 17148
5
Error: Unable to access jarfile C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\webdriver-manager\selenium\selenium-server-standalone-3.5.3.jar
6
[15:56:32] I/start - Selenium Standalone has exited with code 1
解决方法
重装一下 , webdriver-manager update
因为环境坏了 , 或者不是最新版
服务正常了 : ( 最下面一行没有结束 , 光标会一直闪烁 ) 提示 Selenium Server is up and running
C:\Users\zhangqiang>webdriver-manager start
[10:26:31] I/start - java -Dwebdriver.chrome.driver=C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\_webdriver-manager@12.0.6@webdriver-manager\selenium\chromedriver_2.33.exe -Dwebdriver.gecko.driver=C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\_webdriver-manager@12.0.6@webdriver-manager\selenium\geckodriver-v0.19.0.exe -jar C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\_webdriver-manager@12.0.6@webdriver-manager\selenium\selenium-server-standalone-3.6.0.jar -port 4444
[10:26:31] I/start - seleniumProcess.pid: 82572
10:26:34.618 INFO - Selenium build info: version: '3.6.0', revision: '6fbf3ec767'
10:26:34.632 INFO - Launching a standalone Selenium Server
2017-10-23 10:26:34.765:INFO::main: Logging initialized @2565ms to org.seleniumhq.jetty9.util.log.StdErrLog
10:26:35.042 INFO - Driver class not found: com.opera.core.systems.OperaDriver
10:26:35.396 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform WIN8_1
10:26:35.665 INFO - Using the passthrough mode handler
2017-10-23 10:26:35.815:INFO:osjs.Server:main: jetty-9.4.5.v20170502
2017-10-23 10:26:35.993:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.ServletContextHandler@5a8e6209{/,null,STARTING} has uncovered http methods for path: /
2017-10-23 10:26:36.048:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@5a8e6209{/,null,AVAILABLE}
2017-10-23 10:26:36.348:INFO:osjs.AbstractConnector:main: Started ServerConnector@614ddd49{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-10-23 10:26:36.354:INFO:osjs.Server:main: Started @4154ms
10:26:36.361 INFO - Selenium Server is up and running
x
1
C:\Users\zhangqiang>webdriver-manager start
2
[10:26:31] I/start - java -Dwebdriver.chrome.driver=C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\_webdriver-manager@12.0.6@webdriver-manager\selenium\chromedriver_2.33.exe -Dwebdriver.gecko.driver=C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\_webdriver-manager@12.0.6@webdriver-manager\selenium\geckodriver-v0.19.0.exe -jar C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\_webdriver-manager@12.0.6@webdriver-manager\selenium\selenium-server-standalone-3.6.0.jar -port 4444
3
[10:26:31] I/start - seleniumProcess.pid: 82572
4
10:26:34.618 INFO - Selenium build info: version: '3.6.0', revision: '6fbf3ec767'
5
10:26:34.632 INFO - Launching a standalone Selenium Server
6
2017-10-23 10:26:34.765:INFO::main: Logging initialized @2565ms to org.seleniumhq.jetty9.util.log.StdErrLog
7
10:26:35.042 INFO - Driver class not found: com.opera.core.systems.OperaDriver
8
10:26:35.396 INFO - Driver provider class org.openqa.selenium.safari.SafariDriver registration is skipped:
9
registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform WIN8_1
10
10:26:35.665 INFO - Using the passthrough mode handler
11
2017-10-23 10:26:35.815:INFO:osjs.Server:main: jetty-9.4.5.v20170502
12
2017-10-23 10:26:35.993:WARN:osjs.SecurityHandler:main: ServletContext@o.s.j.s.ServletContextHandler@5a8e6209{/,null,STARTING} has uncovered http methods for path: /
13
2017-10-23 10:26:36.048:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@5a8e6209{/,null,AVAILABLE}
14
2017-10-23 10:26:36.348:INFO:osjs.AbstractConnector:main: Started ServerConnector@614ddd49{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
15
2017-10-23 10:26:36.354:INFO:osjs.Server:main: Started @4154ms
16
10:26:36.361 INFO - Selenium Server is up and running
17
脚本也启动正常

自动化测试代码执行期间 , 可以做别的事情 , 因为是脚本在操作浏览器
不需要在这之前手动启动浏览器 , 但Selenium 代理服务要先启动
Chrome version must be >= 59.0.3071.0
在WebStorm run 服务 , 但不行
重装一次
文件下载到
C:\Users\zhangqiang\AppData\Roaming\npm\node_modules\protractor\node_modules\_webdriver-manager@12.0.6@webdriver-manager\selenium

7个文件
下载好后
解压太慢 , 我手动解压了

再执行一次更新

仍旧是7个文件 , 没有解压的
还是不行 , 需要update
这个一直都下载失败 geckodriver-v0.18.0-win64.zip
I/update - geckodriver: unzipping geckodriver-v0.18.0.zip
(node:2200) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Invalid filename
报错说文件名有问题 , 所以无法解压 . 但其实是因为 0大小 , 没下载成功 .
自己手动下载 , 然后放到对应的目录里
单击 0 大小的压缩包

成功的 , 用自动下载的

http://localhost:4444/wd/hub/static/resource/hub.html

update 包下载不下来
服务忘了了
本地的谷歌浏览器太久
Protractor 官方在GitHub的 TypeScript 依赖包安装失败
重装试试
其他的正常
run 起来试试
后面有时间再按照你的需求改UI