Git Product home page Git Product logo

jwebdriver's People

Contributors

felizalde avatar itestauipi avatar stngle avatar yaniswang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jwebdriver's Issues

jWebDriver怎么通过cookie方式登录网站?

用UIrecorder录制下来的脚本,因为网站登录是需要验证码的,所以回放肯定是不成功的,就想通过cookie的方式看能不能登录,尝试用driver.cookie('test', '123')方法,发现是不行的。

使用firefox浏览器运行脚本报错

 var JWebDriver = require('jwebdriver');
 var driver = new JWebDriver();
 driver.session("firefox")
     .url('https://www.baidu.com/')
     .find('#kw')
     .val('mp3')
     .submit()
     .title()
     .then(function(title){
         console.log(title);
     })
     .close();

运行报错

(node:88768) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Unrecognized channel: ANY
Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'
System info: host: 'XXXX-PC', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_111'
Driver info: driver.version: FirefoxDriver
(node:88768) 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.

如何设置浏览器启动时加载插件?

我想在chrome浏览器启动时加载一个第三方插件,selenium里面直接通过options.addExtensions(new File("/path/to/extension.crx"));就可以设置了,但jWebDriver这里要怎么设置呢?

在子域下设置父域cookie失败

步骤:

  1. 跳转到login页面
driver.url("https://login.test.com")
  1. set cookie
// 失败
driver.cookie("ticket", "something", {
  domain: 'test.com'
}) 
// 成功
driver.cookie("ticket", "something", {
  domain: 'login.test.com'
}) 
  1. 尝试直接通过document.cookie设置,可以成功

问题

  1. 是否支持子域设置父域cookie,该怎么做?

IE Firefox浏览器执行失败

非常感谢您开源的jWebDriver,非常适合做web项目测试。
我按照首页步骤操作后,现在chrome和edge可以使用,但是ie和firefox执行node.js示例脚本时出现错误。

脚本如下
var JWebDriver = require('jwebdriver');
var driver = new JWebDriver();
driver.session("ie")
.url('https://www.baidu.com/')
.find('#kw')
.val('mp3')
.submit()
.title()
.then(function(title){
console.log(title);
});

错误日志如下
IE浏览器
(node:13236) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error setting arguments for script
For documentation on this error, please visit: http://seleniumhq.org/exceptions/stale_element_reference.html
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z'
System info: host: 'PC016', ip: '192.168.2.78', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_151'
Driver info: driver.version: unknown
(node:13236) [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.

Firefox浏览器
(node:2992) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Web element reference not seen before: undefined
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.7.1', revision: '8a0099a', time: '2017-11-06T21:07:36.161Z'
System info: host: 'PC016', ip: '192.168.2.78', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_151'
Driver info: driver.version: unknown
(node:2992) [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.

我的环境
Windows 10 64bit
IE 11.125.162969.0
Firefox 57.02 64bit
[email protected]
[email protected]
[email protected]
selenium-server-standalone-3.7.1.jar
2.33-x64-chromedriver
3.7.0-x64-IEDriverServer.exe
0.19.1-x64-geckodriver
16299-MicrosoftEdgeDriver.exe
ie浏览器按照selenium的要求做了权限配置。

我已验证这个环境下,单独使用selenium server能够正常操作各浏览器,我想可以排除selenium server和selenium webdriver的问题。
调查后,我想问题缩小到在jwebdriver这个范围内。
所以想咨询一下,为什么会出现这个问题,jWebDriver对环境(selenium、浏览器等)有什么要求吗?

期待您的回复

exec 函数一直返回超时,求解

it('click: 删除分类', async function () {
    await driver.sleep(300).wait('#root', 30000).then(function (root) {
        return driver.sleep(300).exec('return arguments[0].shadowRoot', root)
            .then(function (ele) {
                return ele.find('#iconshanchu', 30000).click();
            })
    });
});

有没有哪位大佬帮忙看看脚本哪里有问题~!!

image

jWebDriver是否支持手机Safari和Chrome?

我想利用jWebDriver实现以下需求

  1. iOS手机Safari的脚本录制和自动测试。
  2. Android手机Chrome的脚本录制和自动测试。

我有两个问题

  1. 我看到说明文档中提到jWebDriver通过macaca支持原生App和WebView。
    请问是否支持手机浏览器?
  2. uirecorder为什么不支持手机浏览器的录制。
    是没有实现?还是jwebdriver和macaca底层框架就不支持?

报错 Error: the object capabilities

系统环境:
docker version

Client: Docker Engine - Community
 Version:           20.10.1

docker-compose.yml 内容:
# To start Docker in Swarm mode, you need to run `docker swarm init`
# To deploy the Grid, `docker stack deploy -c docker-compose.yml grid`
# Stop with `docker stack rm grid`


version: '3.7'

services:
  hub:
   image: selenium/hub:3.141.59
   environment:
    TZ: Asia/Shanghai
    JAVA_OPTS: -Xmx8192m
    POOL_MAX: 30000
    GRID_NEW_SESSION_WAIT_TIMEOUT: -1
    GRID_JETTY_MAX_THREADS: -1
    GRID_NODE_POLLING: 5000
    GRID_CLEAN_UP_CYCLE: 5000
    GRID_TIMEOUT: 120
    GRID_BROWSER_TIMEOUT: 120
    GRID_MAX_SESSION: 18000
    GRID_UNREGISTER_IF_STILL_DOWN_AFTER: 120
    GRID_DEBUG: "true"
   ports:
     - "4444:4444"

  chrome:
    image:  selenium/node-chrome:3.141.59
    volumes:
      - /dev/shm:/dev/shm
    environment:
      HUB_HOST: hub
      HUB_PORT: 4444
    deploy:
        replicas: 10
    entrypoint: bash -c 'SE_OPTS="-host $$HOSTNAME" /opt/bin/entry_point.sh'

报错:

commons/start_mode/start_mode_Inte : chrome
    1) "before all" hook
    2) "after all" hook


  0 passing (724ms)
  2 failing

  1) commons/start_mode/start_mode_Inte : chrome
       "before all" hook:
     Error: the object {
  "capabilities": {
    "acceptInsecureCerts": false
    "browserName": "chrome"
    "browserVersion": "88.0.4324.96"
    "chrome": {
      "chromedriverVersion": "88.0.4324.96 (68dba2d8a0b149a1d3afac56fa74648032bcf46b-refs/b
      "userDataDir": "/tmp/.com.google.Chrome.baFK1C"
    }
    "goog:chromeOptions": {
      "debuggerAddress": "localhost:41536"
    }
    "networkConnectionEnabled": false
    "pageLoadStrategy": "normal"
    "platformName": "linux"
    "proxy": {}
    "setWindowRect": true
    "strictFileInteractability": false
    "timeouts": {
      "implicit": 0
      "pageLoad": 300000
      "script": 30000
    }
    "unhandledPromptBehavior": "dismiss and notify"
    "webauthn:extension:largeBlob": true
    "webauthn:virtualAuthenticators": true
    "webdriver.remote.sessionid": "490f0dca7efedf7a4e8d7f537d5980b1"
  }
  "sessionId": "490f0dca7efedf7a4e8d7f537d5980b1"
} was thrown, throw an Error :)
      at <anonymous>
      at process._tickCallback (internal/process/next_tick.js:189:7)

Support "web element identifier" in updated W3C standard used by Firefox's GeckoDriver

Running the current jWebdriver against Selenium 3+ and GeckoDriver, elements are not correctly identified.

Older implementation expected by jWebDriver when a call to retrieve an element. The body response to the wire protocol will use: "value":[{"ELEMENT":"1"}]

Newer implementation used by GeckoDriver and presumably by future webdriver implementation, the body response contains the element value as: "value":[{"element-6066-11e4-a52e-4f735466cecf":"4ba8d8d3-5f4d-4007-99e9-30fac0d76f3b"}]

You can see the hard-coded attribute element-6066-11e4-a52e-4f735466cecf that should be referenced in the W3C docs for element

To support both standards, I am submitting a pull request with the updated correction.

selenium grid的hub和node模式,ie无法启动

启动hub和node的BAT命令:

#hub
selenium-standalone start -- -role hub
#node
selenium-standalone start -- -role node -hub http://localhost:4444/grid/register

使用uirecorder+jwebdriver+node.js

非hub&node模式

  • 使用uirecorder录制脚本
  • 使用命令selenium-standalone start运行webdriver
  • 运行脚本mocha test.spec.js
  • ie和chrome可以打开并成功运行

hub&node模式

  • 使用uirecorder录制脚本
  • 使用命令运行selenium grid的hub和node
  • 修改config.json的webdriverip,运行脚本mocha test.spec.js
  • chrome可以打开并成功运行,但是IE无法启动,报错信息:
 1) d2.spec : ie 11 "before all" hook:
     Error: the string "Error forwarding the new session cannot find : Capabilities [{ie.ensureCleanSession=true, browserName=internet explorer, version=11, platform=ANY}]" was thrown, throw an Error :)
      at process._tickCallback (internal/process/next_tick.js:103:7)

  2) d2.spec : ie 11 "after all" hook:
     Error: the string "Error forwarding the new session cannot find : Capabilities [{ie.ensureCleanSession=true, browserName=internet explorer, version=11, platform=ANY}]" was thrown, throw an Error :)

使用selenium2+webdriver+python

非hub&node模式

  • 使用python手写一个脚本,代码:
#-*- coding=utf-8 -*-
from selenium import webdriver
import os
iedriver = r"C:\Users\gujiangfei\Desktop\uirecorder\selenium_grid_2\.selenium\iedriver\2.53.1-x64-IEDriverServer.exe"
os.environ["webdriver.ie.driver"] = iedriver
driver = webdriver.Ie(iedriver)
driver.get("http://www.baidu.com")
  • IE11可以正常运行

hub&node模式

  • 使用python手写一个脚本,代码:
#-*- coding=utf-8 -*-
from selenium import webdriver
import os
c = webdriver.DesiredCapabilities.INTERNETEXPLORER
driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=c)
driver.get("http://www.baidu.com")
  • IE11可以正常运行

通过以上对比测试,可以排除selenium-standalone.jar和iedriver.exe的版本问题,请大神看下是否是jwebdriver的问题导致使用selenium grid时候导致无法启动IE,万分感谢!

getScreenshot cause 'toString' of undefined

describe::
image

After analysis, I found local machine don't install GraphicsMagick or ImageMagick ; it's well with GraphicsMagick or ImageMagick installed;

refernce document:
https://www.npmjs.com/package/gm
aheckmann/gm#359
\

Because this error is ignored here, this problem is difficult to find...

// in browser.js
png64 = yield new Promise((resolve) => gmShot.toBuffer('PNG', (error, buffer) => resolve(buffer)));
//==>
png64 = await new Promise((resolve,reject) => gmShot.toBuffer('PNG', (error, buffer) => error?reject(error): resolve(buffer)}));

how can location a random generated ID ?

i have a question is that a element id is random . How can I location
image
Css selector :
#node_jkagp1pm-jnpei0mr-node_jkagp1pr > div > div.kuma-uxform-field.kuma-uxform-field.kuma-select-uxform-field.vc-select-field.node_jkagp1pm-jnpei0mr-node_jkagp1pt.kuma-uxform-field__layout-h > div > ul > li > div > div > div > div.kuma-select2-selection__placeholder
Xpath://*[@id="node_jkagp1pm-jnpei0mr-node_jkagp1pr"]/div/div[1]/div/ul/li/div/div/div/div[1]
“node_jkagp1pm-jnpei0mr-node_jkagp1pr” is random generated 。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.