selenium-ide 开发手册

selenium-ide 开发手册

https://github.com/SeleniumHQ/selenium-ide

peru

包管理器,用于在项目中包含其他人的代码

  • Peru is a tool for including other people's code in your projects. It fetches from anywhere -- git, hg, svn, tarballs -- and puts files wherever you like. Peru helps you track exact versions of your dependencies, so that your history is always reproducible. And it fits inside your scripts and Makefiles, so your build stays simple and foolproof.
  • https://github.com/buildinspace/peru#installation

安装

  • pip3 install peru

同步

peru sync
peru reup

清理

peru clean
lerna clean

peru.yaml

imports:   # This is where we want peru to put the module.
  atoms: packages/selenium-ide/selenium/atoms
  selenium-atoms: packages/selenium-ide/selenium/selenium-atoms
  selenium-core: packages/selenium-ide/selenium/selenium-core-scripts
  webdriver: packages/selenium-ide/selenium/webdriver
  third_party: packages/selenium-ide/selenium/third_party

git module atoms:
  url: https://github.com/SeleniumHQ/selenium
  rev: 07c4a7c99eb1ac8f2d82fd92141adcd3eefd5e42
  export: "javascript/atoms"

git module selenium-atoms:
  url: https://github.com/SeleniumHQ/selenium
  rev: 07c4a7c99eb1ac8f2d82fd92141adcd3eefd5e42
  export: "javascript/selenium-atoms"

git module selenium-core:
  url: https://github.com/SeleniumHQ/selenium
  rev: 07c4a7c99eb1ac8f2d82fd92141adcd3eefd5e42
  export: "javascript/selenium-core/scripts"

git module webdriver:
  url: https://github.com/SeleniumHQ/selenium
  rev: 07c4a7c99eb1ac8f2d82fd92141adcd3eefd5e42
  export: "javascript/webdriver/atoms"

git module third_party:
  url: https://github.com/SeleniumHQ/selenium
  rev: 07c4a7c99eb1ac8f2d82fd92141adcd3eefd5e42
  export: "third_party/js"

peru 命令使用说明:

Usage:
    peru [-hqv] [--file=<file>] [--sync-dir=<dir>] [--state-dir=<dir>]
         [--cache-dir=<dir>] [--file-basename=<name>] <command> [<args>...]
    peru [--help|--version]

Commands:
    sync      fetch imports and copy them to your project
    reup      update revision information for your modules
    clean     delete imports from your project
    copy      copy files directly from a module to somewhere else
    override  substitute a local directory for the contents of a module
    module    get information about the modules in your project
    help      show help for subcommands, same as -h/--help

Options:
    -h --help             so much help
    -q --quiet            don't print anything
    -v --verbose          print everything

    --file=<file>
        The project file to use instead of 'peru.yaml'. This must be used
        together with --sync-dir.
    --sync-dir=<dir>
        The root directory for your imports, instead of the directory
        containing 'peru.yaml'. This must be used together with --file.
    --state-dir=<dir>
        The directory where peru keeps all of its metadata, including the cache
        and the current imports tree. Defaults to '.peru' next to 'peru.yaml'.
    --cache-dir=<dir>
        The directory for caching all the files peru fetches. Defaults to
        '.peru/cache', or $PERU_CACHE_DIR if it's defined.
    --file-basename=<name>
        An alternative filename (not a path) for 'peru.yaml'. As usual, peru
        will search the current dir and its parents for this file, and import
        paths will be relative to it. Incompatible with --file.

yarn

是什么

  • Yarn is a package ( package.json ) manager for your code. It allows you to use and share code

install

curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --nightly

Usage

  • Starting a new project
yarn init

Adding a dependency

yarn add [package]
yarn add [package]@[version]
yarn add [package]@[tag]

Adding a dependency to different categories of dependencies

Add to devDependencies, peerDependencies, and optionalDependencies respectively:

yarn add [package] --dev
yarn add [package] --peer
yarn add [package] --optional

Upgrading a dependency

yarn upgrade [package]
yarn upgrade [package]@[version]
yarn upgrade [package]@[tag]

Removing a dependency

yarn remove [package]

Installing all the dependencies of project

yarn

or

yarn install

(https://yarnpkg.com/en/docs/cli/install)

清理缓存

$ yarn cache clean

指定端口

$ yarn --mutex network:30330

lerna

是什么呢?

  • A tool for managing JavaScript projects with multiple packages.

工作原理

  • 自动解决packages之间的依赖关系
  • 通过git 检测文件改动,自动发布
  • 根据git 提交记录,自动生成CHANGELOG

全局安装lerna

npm install lerna -g

开发程序

清缓存依赖:

yarn cache clean

清理 peru 代码缓存:

peru clean & peru sync

下载所有依赖:

yarn --mutex network:30333

构建工程:

$ lerna bootstrap
lerna notice cli v3.6.0
lerna info Bootstrapping 5 packages
lerna info Installing external dependencies
  • 背后是:
lerna run build --ignore selenium-ide-extension-boilerplate

Build the extension

  • yarn build

等同于:

npm run-script build
  • yarn build:webdriver

  • yarn build:ext

  • 完整命令集

    *     "start": "cd packages/selenium-ide && yarn start",
    *     "build": "lerna run build --ignore selenium-ide-extension-boilerplate",
    *     "build:ext": "cd packages/selenium-ide && yarn build-dev",
    *     "build:runner": "cd packages/selenium-side-runner && yarn build",
    *     "build:selianize": "cd packages/selianize && yarn build",
    *     "build:webdriver": "cd packages/browser-webdriver && yarn build",
    *     "build:webdriver:dev": "cd packages/browser-webdriver && yarn build:dev",
    *     "build:ext:prod": "cd packages/selenium-ide && yarn build",
    *     "pack:chrome": "cd packages/selenium-ide && yarn build-chrome",
    *     "pack:firefox": "cd packages/selenium-ide && yarn build-firefox",
    *     "pack:runner": "cd packages/selenium-side-runner && yarn pkg",
    *     "test": "jest",
    *     "test:ext": "jest --testMatch \"**/packages/selenium-ide/tests/**/*.spec.js\"",
    *     "test:runner": "cd tests/examples && node ../../packages/selenium-side-runner/dist/index.js *.side",
    *     "test:webdriver": "jest --testMatch \"**/packages/browser-webdriver/tests/**/*.spec.js\"",
    *     "lint": "yarn lint:scripts && yarn lint:styles",
    *     "lint:scripts": "eslint \"packages/*/src/**/*.js\" \"packages/*/src/**/*.jsx\" \"packages/*/__tests__/**/*.js\" \"packages/*/tests/**/*.js\" \"packages/*/__mocks__/**/*.js\" --ignore-pattern=\"extension-boilerplate\"",
    *     "lint:styles": "stylelint \"packages/selenium-ide/src/neo/**/*.css\"",
    *     "postinstall": "lerna bootstrap"

.pem 文件:打包 chrome 插件时使用

openssl genrsa -out selenium-ide.pem 2048
"./build.sh build ../../selenium-ide.pem 1>/dev/null && mkdir -p dist && mv build.crx dist/selenium-ide.crx && echo \"Wrote dist/selenium-ide.crx\""

开发过程剪辑:

$ peru sync
或者: peru reup 更新依赖 code

╶ atoms: Receiving objects:   8% (34366/426117), 40.00 MiB | 5.53 MiB/s 

$ yarn --ignore-engines

yarn install v1.13.0-20181209.2324
[1/4] ?  Resolving packages...
[2/4] ?  Fetching packages...
[3/4] ?  Linking dependencies...
warning " > babel-jest@23.6.0" has unmet peer dependency "babel-core@^6.0.0 || ^7.0.0-0".
[4/4] ?  Building fresh packages...
$ lerna bootstrap
lerna notice cli v3.4.3
lerna info Bootstrapping 5 packages
lerna info Installing external dependencies
lerna info Symlinking packages and binaries
lerna success Bootstrapped 5 packages
✨  Done in 288.93s.

$ npm run-script build

> selenium-ide@ build /Users/jack/ui/selenium-ide
> lerna run build --ignore selenium-ide-extension-boilerplate

lerna notice cli v3.4.3
lerna info filter [ '!selenium-ide-extension-boilerplate' ]
lerna info Executing command in 4 packages: "yarn run build"
yarn run v1.13.0-20181209.2324
$ rollup -c
Done in 4.75s.
yarn run v1.13.0-20181209.2324
$ yarn run browserify src/index.js -s browser-webdriver -o build/webdriver.js
$ /Users/jack/ui/selenium-ide/packages/browser-webdriver/node_modules/.bin/browserify src/index.js -s browser-webdriver -o build/webdriver.js
Done in 5.11s.
yarn run v1.13.0-20181209.2324
$ babel -d dist src --ignore=__test__
src/capabilities.js -> dist/capabilities.js
src/child.js -> dist/child.js
src/config.js -> dist/config.js
src/index.js -> dist/index.js
src/npm.js -> dist/npm.js
src/proxy.js -> dist/proxy.js
src/versioner.js -> dist/versioner.js
Done in 1.13s.



yarn run v1.13.0-20181209.2324
$ rm -rf build && env NODE_ENV=production webpack
Hash: a0b9a689f65fddd040b4
Version: webpack 3.12.0
Time: 119676ms
                                      Asset       Size  Chunks                    Chunk Names
media/selenium_blue_white32@3x.84ab23d0.svg    3.62 kB          [emitted]         
            media/selenium-ide.461193c2.ttf    7.44 kB          [emitted]         
            media/selenium-ide.9b39b00c.svg    21.8 kB          [emitted]         
                                playback.js    99.7 kB       0  [emitted]         playback
                                  record.js    39.4 kB       1  [emitted]         record
                                     neo.js    2.45 MB       2  [emitted]  [big]  neo
                                   atoms.js     494 kB       3  [emitted]  [big]  atoms
                              background.js      24 kB       4  [emitted]         background
                               polyfills.js    7.15 kB       5  [emitted]         polyfills
                                  escape.js    2.99 kB       6  [emitted]         escape
                            playback.js.map     387 kB       0  [emitted]         playback
                              record.js.map     162 kB       1  [emitted]         record
                                 neo.js.map    8.56 MB       2  [emitted]         neo
                               atoms.js.map    2.23 MB       3  [emitted]         atoms
                          background.js.map     113 kB       4  [emitted]         background
                           polyfills.js.map    40.6 kB       5  [emitted]         polyfills
                              escape.js.map    14.2 kB       6  [emitted]         escape
                              highlight.css  952 bytes          [emitted]         
           vendor/selenium-browserdetect.js    5.27 kB          [emitted]         
                           vendor/global.js  825 bytes          [emitted]         
                                  prompt.js    7.25 kB          [emitted]         
                           ../manifest.json    1.74 kB          [emitted]         
                               indicator.js  694 bytes          [emitted]         
                          ../bootstrap.html    1.57 kB          [emitted]         
                          ../indicator.html    1.03 kB          [emitted]         
                   ../icons/icon_menu32.png    1.22 kB          [emitted]         
                   ../icons/icon_menu64.png    2.76 kB          [emitted]         
                   ../icons/icon_menu16.png  552 bytes          [emitted]         
                       ../icons/icon128.png    5.88 kB          [emitted]         
                        ../icons/icon16.png  612 bytes          [emitted]         
                        ../icons/icon64.png    2.91 kB          [emitted]         
                        ../icons/icon32.png    1.29 kB          [emitted]         
                              ../index.html  315 bytes          [emitted]         
  [41] ./common/utils.js 1.5 kB {1} {2} {4} [built]
  [77] ./content/closure-polyfill.js 2.9 kB {3} [built]
 [136] ./content/commands-api.js 6.84 kB {0} [built]
 [149] ./content/escape.js 5.11 kB {0} {6} [built]
 [229] ./content/selenium-api.js 122 kB {0} [built]
 [320] multi ./content/setup 28 bytes {5} [built]
 [321] ./content/setup.js 1.28 kB {5} [built]
 [322] multi ./content/commands-api 28 bytes {0} [built]
 [385] multi ./background/background 28 bytes {4} [built]
 [386] ./background/background.js 5.09 kB {4} [built]
 [387] multi ./content/record 28 bytes {1} [built]
 [388] ./content/record.js 19.5 kB {1} [built]
 [391] multi ./content/escape 28 bytes {6} [built]
 [392] multi react-hot-loader/patch ./neo/containers/Root 40 bytes {2} [built]
 [396] ./neo/containers/Root/index.jsx 1.61 kB {2} [built]
    + 1083 hidden modules
Child html-webpack-plugin for "../index.html":
     1 asset
       [0] ../node_modules/html-webpack-plugin/lib/loader.js!./neo/index.html 720 bytes {0} [built]
        + 3 hidden modules
Done in 129.29s.
lerna success run Ran npm script 'build' in 4 packages:
lerna success - browser-webdriver
lerna success - selenium-ide-extension
lerna success - selenium-side-runner
lerna success - selianize

到 selenium-ide 工程目录下面构建:

selenium-ide/packages/selenium-ide$ webpack
Hash: 64055d2df5f64506be6d
Version: webpack 3.12.0
Time: 51650ms
                                      Asset       Size  Chunks                    Chunk Names
media/selenium_blue_white32@3x.84ab23d0.svg    3.62 kB          [emitted]         
            media/selenium-ide.461193c2.ttf    7.44 kB          [emitted]         
            media/selenium-ide.9b39b00c.svg    21.8 kB          [emitted]         
                                playback.js     617 kB       0  [emitted]  [big]  playback
                                  record.js     298 kB       1  [emitted]  [big]  record
                                     neo.js      18 MB       2  [emitted]  [big]  neo
                                   atoms.js    4.28 MB       3  [emitted]  [big]  atoms
                              background.js     227 kB       4  [emitted]         background
                               polyfills.js    76.8 kB       5  [emitted]         polyfills
                                  escape.js    17.9 kB       6  [emitted]         escape
                              highlight.css  952 bytes          [emitted]         
                                  prompt.js    7.25 kB          [emitted]         
                           vendor/global.js  825 bytes          [emitted]         
           vendor/selenium-browserdetect.js    5.27 kB          [emitted]         
                          ../indicator.html    1.03 kB          [emitted]         
                          ../bootstrap.html    1.57 kB          [emitted]         
                               indicator.js  694 bytes          [emitted]         
                           ../manifest.json    1.74 kB          [emitted]         
                   ../icons/icon_menu16.png  552 bytes          [emitted]         
                       ../icons/icon128.png    5.88 kB          [emitted]         
                   ../icons/icon_menu32.png    1.22 kB          [emitted]         
                   ../icons/icon_menu64.png    2.76 kB          [emitted]         
                        ../icons/icon64.png    2.91 kB          [emitted]         
                        ../icons/icon16.png  612 bytes          [emitted]         
                        ../icons/icon32.png    1.29 kB          [emitted]         
                              ../index.html  315 bytes          [emitted]         
  [41] ./common/utils.js 2.46 kB {1} {2} {4} [built]
  [80] ./content/closure-polyfill.js 2.9 kB {3} [built]
 [141] ./content/commands-api.js 7.77 kB {0} [built]
 [154] ./content/escape.js 5.96 kB {0} {6} [built]
 [234] ./content/selenium-api.js 124 kB {0} [built]
 [328] multi ./content/setup 28 bytes {5} [built]
 [329] ./content/setup.js 1.36 kB {5} [built]
 [330] multi ./content/commands-api 28 bytes {0} [built]
 [393] multi ./background/background 28 bytes {4} [built]
 [394] ./background/background.js 6.57 kB {4} [built]
 [395] multi ./content/record 28 bytes {1} [built]
 [396] ./content/record.js 23.2 kB {1} [built]
 [399] multi ./content/escape 28 bytes {6} [built]
 [400] multi react-hot-loader/patch ./neo/containers/Root 40 bytes {2} [built]
 [404] ./neo/containers/Root/index.jsx 1.82 kB {2} [built]
    + 1094 hidden modules
Child html-webpack-plugin for "../index.html":
     1 asset
       [0] ../node_modules/html-webpack-plugin/lib/loader.js!./neo/index.html 720 bytes {0} [built]
        + 3 hidden modules

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

光剑书架上的书

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值