New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

webdriverjs vs selenium-wedriverjs (question) #138

Closed
dmitrym0 opened this Issue Jan 10, 2014 · 18 comments

Comments

Projects
None yet
8 participants
@dmitrym0

Hello everyone,

I apologize in advance if I'm asking stupid questions.

First, this project is in fact different from selenium-wedriver-js is that correct? The name threw me off for a little while :(

Secondly, how does webdriverio compare to selenium-webdriverjs? selenium-webdriverjs looks very java-y to me, on the other hand I can't quite fiigure out how webdriverio (yours) does async stuff.

I basically need help choosing one or the other. Thanks!

@christian-bromann

This comment has been minimized.

Show comment
Hide comment
@christian-bromann

christian-bromann Jan 10, 2014

Member

hi @dmitrym0

that is not a stupid question in fact often asked! I answer that a lot. Basically both have the same purpose. There is also a library called WD.js which is also a selenium runner for node. They all do quiet the same but have a different level of development and a different syntax.

I've never used one of the other libraries before so I can just tell you about this one. We're trying to provide a selenium runner which is easy to use, highly extendable and compatible with all common JavaScript test frameworks. It uses an own chain API to execute all async commands in right order. The specialty of this library is that we wrap all JSONWire protocol commands in useful actions commands. So you don't have to care about to get an element first and then call the click command; you just execute the click with a selector as parameter. Here is a simplified example:

selenium-webdriverjs:

driver.get('http://www.google.com');
driver.findElement(webdriver.By.id('q')).sendKeys('webdriver');
driver.findElement(webdriver.By.id('btnG')).click();

WD.js

browser
  .get("http://www.google.com")
  .elementById('q')
  .sendKeys('webdriver')
  .elementById('btnG')
  .click()

Now in this library:

client
    .url('http://google.com')
    .setValue('#q','webdriver')
    .click('#btnG')

WebdriverIO has also almost all protocol commands implemented, so you can do the same with the standard JSONWire protocol commands.

client
    .url('http://google.com')
    .element('#q', function(err,res) {
        client.elementIdValue(res.value.ELEMENT, 'webdriver');
    })
    .element('#btnG', function(err,res) {
        client.elementIdClick(res.value.ELEMENT);
    });

Each one has its own flavor, you need to decide which one fits most to you. I hope this clarifies it a bit. I'ld like to help you if you have any problems setting up your tests. But I thing it should be pretty easy and straight forward. You can find a list of example tests here.

cheers

Member

christian-bromann commented Jan 10, 2014

hi @dmitrym0

that is not a stupid question in fact often asked! I answer that a lot. Basically both have the same purpose. There is also a library called WD.js which is also a selenium runner for node. They all do quiet the same but have a different level of development and a different syntax.

I've never used one of the other libraries before so I can just tell you about this one. We're trying to provide a selenium runner which is easy to use, highly extendable and compatible with all common JavaScript test frameworks. It uses an own chain API to execute all async commands in right order. The specialty of this library is that we wrap all JSONWire protocol commands in useful actions commands. So you don't have to care about to get an element first and then call the click command; you just execute the click with a selector as parameter. Here is a simplified example:

selenium-webdriverjs:

driver.get('http://www.google.com');
driver.findElement(webdriver.By.id('q')).sendKeys('webdriver');
driver.findElement(webdriver.By.id('btnG')).click();

WD.js

browser
  .get("http://www.google.com")
  .elementById('q')
  .sendKeys('webdriver')
  .elementById('btnG')
  .click()

Now in this library:

client
    .url('http://google.com')
    .setValue('#q','webdriver')
    .click('#btnG')

WebdriverIO has also almost all protocol commands implemented, so you can do the same with the standard JSONWire protocol commands.

client
    .url('http://google.com')
    .element('#q', function(err,res) {
        client.elementIdValue(res.value.ELEMENT, 'webdriver');
    })
    .element('#btnG', function(err,res) {
        client.elementIdClick(res.value.ELEMENT);
    });

Each one has its own flavor, you need to decide which one fits most to you. I hope this clarifies it a bit. I'ld like to help you if you have any problems setting up your tests. But I thing it should be pretty easy and straight forward. You can find a list of example tests here.

cheers

@vvo

This comment has been minimized.

Show comment
Hide comment
@vvo

vvo Jan 12, 2014

Contributor

Very nice answert @christian-bromann I think this should be linked in the readme.md now.

Contributor

vvo commented Jan 12, 2014

Very nice answert @christian-bromann I think this should be linked in the readme.md now.

@dmitrym0

This comment has been minimized.

Show comment
Hide comment
@dmitrym0

dmitrym0 Jan 13, 2014

@christian-bromann, thank you very much for explaining this to me. It helps very much.

If I can ask for some more of your time. I've written a script in selenium-webdriverjs that illustrates my current use case nicely.

It:

  • opens up a wikipedia page
  • finds all of the text paragraphs on the page
  • clicks on the first and the 5th paragraph to select them

I would like to reproduce this in webdriverio, however I can't seem to figure out how to select text. Can you help me with that? Thanks!

Text of my current selenium-webdriverjs is below:

var assert = require('assert'),
test = require('selenium-webdriver/testing'),
webdriver = require('selenium-webdriver');

var driver = new webdriver.Builder().
    usingServer("http://localhost:9515").
    withCapabilities(webdriver.Capabilities.chrome()).
    build();

test.describe('selection', function() {
    test.it('should be able to select two paragraphs', function() {
        console.log("Request URL");
        driver.get("http://en.wikipedia.org/wiki/Computer_programming");
        var startParagraph, endParagraph;
        driver.sleep(500).then(function() {
            console.log("Getting all paragraphs");
            var allPs = driver.findElements({tagName: 'p'}).then();

            allPs.then(function(allParagraphs){
                console.log("Got paragraphs.");
                allParagraphs[1].then(function(startParagraphvalue){
                    startParagraph = startParagraphvalue
                    console.log("Resolved paragraph 1")
                });

                allParagraphs[5].then(function(endParagraphvalue){
                    endParagraph = endParagraphvalue
                    console.log("Resolved paragrpah 2" + endParagraphvalue);
                });
            });
        }).then(function() {
            console.log("Trying to select stuff now");
            new webdriver.ActionSequence(driver).
                keyDown(webdriver.Key.SHIFT).
                click(startParagraph).
                click(endParagraph).
                keyUp(webdriver.Key.SHIFT).
                perform().then(function(){
                    console.log("Done selection?");
            });
        });


    });
});

@christian-bromann, thank you very much for explaining this to me. It helps very much.

If I can ask for some more of your time. I've written a script in selenium-webdriverjs that illustrates my current use case nicely.

It:

  • opens up a wikipedia page
  • finds all of the text paragraphs on the page
  • clicks on the first and the 5th paragraph to select them

I would like to reproduce this in webdriverio, however I can't seem to figure out how to select text. Can you help me with that? Thanks!

Text of my current selenium-webdriverjs is below:

var assert = require('assert'),
test = require('selenium-webdriver/testing'),
webdriver = require('selenium-webdriver');

var driver = new webdriver.Builder().
    usingServer("http://localhost:9515").
    withCapabilities(webdriver.Capabilities.chrome()).
    build();

test.describe('selection', function() {
    test.it('should be able to select two paragraphs', function() {
        console.log("Request URL");
        driver.get("http://en.wikipedia.org/wiki/Computer_programming");
        var startParagraph, endParagraph;
        driver.sleep(500).then(function() {
            console.log("Getting all paragraphs");
            var allPs = driver.findElements({tagName: 'p'}).then();

            allPs.then(function(allParagraphs){
                console.log("Got paragraphs.");
                allParagraphs[1].then(function(startParagraphvalue){
                    startParagraph = startParagraphvalue
                    console.log("Resolved paragraph 1")
                });

                allParagraphs[5].then(function(endParagraphvalue){
                    endParagraph = endParagraphvalue
                    console.log("Resolved paragrpah 2" + endParagraphvalue);
                });
            });
        }).then(function() {
            console.log("Trying to select stuff now");
            new webdriver.ActionSequence(driver).
                keyDown(webdriver.Key.SHIFT).
                click(startParagraph).
                click(endParagraph).
                keyUp(webdriver.Key.SHIFT).
                perform().then(function(){
                    console.log("Done selection?");
            });
        });


    });
});
@christian-bromann

This comment has been minimized.

Show comment
Hide comment
@christian-bromann

christian-bromann Jan 13, 2014

Member

With WebdriverIO it is a bit shorter ;-)

var assert = require('assert'),
    client = require('webdriverjs').remote({desiredCapabilities:{browserName:'chrome'}});

client
    .init()
    .url('http://en.wikipedia.org/wiki/Computer_programming')
    .elements('tag name','p',function(err,res) {
        client
            // move to first paragraph to the upper left corner (0,0)
            .moveTo(res.value[0].ELEMENT, 0, 0)
            // press shift key
            .keys('Shift')
            // do left click
            .buttonPress('left')
            // move to 5th paragraph to the lower right corner (1,1)
            .moveTo(res.value[5].ELEMENT,1,1)
            // do left click
            .buttonPress('left')
            // pause for 5000ms to be able to see selected text
            .pause(5000);
    })
    .end();

First we query all elements with tag name p. The res.value object contains an array of elements. Then we just select a text using the shift key. I admit that this is not straightforward for new user because the protocol commands aren't really documented. webdriver.io is gonna to go live soon and will cover that.

Member

christian-bromann commented Jan 13, 2014

With WebdriverIO it is a bit shorter ;-)

var assert = require('assert'),
    client = require('webdriverjs').remote({desiredCapabilities:{browserName:'chrome'}});

client
    .init()
    .url('http://en.wikipedia.org/wiki/Computer_programming')
    .elements('tag name','p',function(err,res) {
        client
            // move to first paragraph to the upper left corner (0,0)
            .moveTo(res.value[0].ELEMENT, 0, 0)
            // press shift key
            .keys('Shift')
            // do left click
            .buttonPress('left')
            // move to 5th paragraph to the lower right corner (1,1)
            .moveTo(res.value[5].ELEMENT,1,1)
            // do left click
            .buttonPress('left')
            // pause for 5000ms to be able to see selected text
            .pause(5000);
    })
    .end();

First we query all elements with tag name p. The res.value object contains an array of elements. Then we just select a text using the shift key. I admit that this is not straightforward for new user because the protocol commands aren't really documented. webdriver.io is gonna to go live soon and will cover that.

@wayneseymour

This comment has been minimized.

Show comment
Hide comment
@wayneseymour

wayneseymour Jan 23, 2014

I'm really starting to lean towards webdriver.io!!!!

I'm really starting to lean towards webdriver.io!!!!

@christian-bromann

This comment has been minimized.

Show comment
Hide comment
@christian-bromann

christian-bromann Jan 23, 2014

Member

@dmitrym0 do you have any further questions?

@wayneseymour great! sounds good

Member

christian-bromann commented Jan 23, 2014

@dmitrym0 do you have any further questions?

@wayneseymour great! sounds good

@christian-bromann

This comment has been minimized.

Show comment
Hide comment
@christian-bromann

christian-bromann Jan 28, 2014

Member

seems to be that there are no further questions. closing.

Member

christian-bromann commented Jan 28, 2014

seems to be that there are no further questions. closing.

@dmitrym0

This comment has been minimized.

Show comment
Hide comment
@dmitrym0

dmitrym0 Jan 28, 2014

Thanks for all your help @christian-bromann !

Thanks for all your help @christian-bromann !

@jimmyeisenhauer

This comment has been minimized.

Show comment
Hide comment
@jimmyeisenhauer

jimmyeisenhauer Feb 10, 2015

curious you and adam wd.js both work at sauce. Plan to keep 2 webdriver node libs going?

curious you and adam wd.js both work at sauce. Plan to keep 2 webdriver node libs going?

@christian-bromann

This comment has been minimized.

Show comment
Hide comment
@christian-bromann

christian-bromann Feb 10, 2015

Member

I don't know where WD.js is going, I started working on webdriver.io long before I joined sauce and all my work I put in here has nothing in common with the stuff I do at sauce. I am doing this all in my free time and enjoy it to contribute to the open source world ;-)

Member

christian-bromann commented Feb 10, 2015

I don't know where WD.js is going, I started working on webdriver.io long before I joined sauce and all my work I put in here has nothing in common with the stuff I do at sauce. I am doing this all in my free time and enjoy it to contribute to the open source world ;-)

@jimmyeisenhauer

This comment has been minimized.

Show comment
Hide comment
@jimmyeisenhauer

jimmyeisenhauer Feb 15, 2015

thanks for the response and the project looks great!

thanks for the response and the project looks great!

@abacaj

This comment has been minimized.

Show comment
Hide comment
@abacaj

abacaj Feb 11, 2016

@christian-bromann I know this is rather old and may have been resolved already but your example of using a pause is a really bad practice in the selenium world and leads to inconclusive results, i.e how do you know it takes 5 seconds and can you guarantee that it will always be 5 seconds?

.pause(5000);

A better approach is to retry with a timeout period, i.e we don't know how long it takes but we will keep retrying for 30 seconds and if we still don't have it then there is obviously an issue.

Is there something in place for this type of approach using webdriver IO?

abacaj commented Feb 11, 2016

@christian-bromann I know this is rather old and may have been resolved already but your example of using a pause is a really bad practice in the selenium world and leads to inconclusive results, i.e how do you know it takes 5 seconds and can you guarantee that it will always be 5 seconds?

.pause(5000);

A better approach is to retry with a timeout period, i.e we don't know how long it takes but we will keep retrying for 30 seconds and if we still don't have it then there is obviously an issue.

Is there something in place for this type of approach using webdriver IO?

@christian-bromann

This comment has been minimized.

Show comment
Hide comment
@christian-bromann

christian-bromann Feb 11, 2016

Member

Yeah, WebdriverIO has a bunch of waitFor* commands. Check out the API

Member

christian-bromann commented Feb 11, 2016

Yeah, WebdriverIO has a bunch of waitFor* commands. Check out the API

@code4arpit

This comment has been minimized.

Show comment
Hide comment
@code4arpit

code4arpit Feb 24, 2016

Hi Christian , I really need your help. I am very much confused in selecting automation testing stack.
Options 1) Webdriver.IO , Selenium standalone and Cucumber.io (A JavaScript Approached) AND
Option 2) WebdriverJS, Selenium JAR and Cucumber JAR (A Java Approached) .

We as a team really had spent a good amount of time and experienced - WebdriverIO is not mature enough as compare to Selenium , Cucumber and Webdriver (java approach) .

I saw your lot of help and comments in the internet and would really appreciate your comments here too.

Hi Christian , I really need your help. I am very much confused in selecting automation testing stack.
Options 1) Webdriver.IO , Selenium standalone and Cucumber.io (A JavaScript Approached) AND
Option 2) WebdriverJS, Selenium JAR and Cucumber JAR (A Java Approached) .

We as a team really had spent a good amount of time and experienced - WebdriverIO is not mature enough as compare to Selenium , Cucumber and Webdriver (java approach) .

I saw your lot of help and comments in the internet and would really appreciate your comments here too.

@arturi arturi referenced this issue Nov 6, 2017

Merged

Refactor end-to-end tests #410

5 of 5 tasks complete
@sumeetp4

This comment has been minimized.

Show comment
Hide comment
@sumeetp4

sumeetp4 Jan 31, 2018

Hi Guys,

I have gone through this thread, but I'm still confused which framework to go for.
I will be testing a mobile application on Android and iOS both, also will be on real devices/simulators.
It will be having need of functions to scroll vertically/horizontally and all.

Please suggest!

Thanks

Hi Guys,

I have gone through this thread, but I'm still confused which framework to go for.
I will be testing a mobile application on Android and iOS both, also will be on real devices/simulators.
It will be having need of functions to scroll vertically/horizontally and all.

Please suggest!

Thanks

@christian-bromann

This comment has been minimized.

Show comment
Hide comment
@christian-bromann

christian-bromann Jan 31, 2018

Member

but I'm still confused which framework to go for.

What am I suppose to say here? I can just recommend to use WebdriverIO. It supports it all.

Member

christian-bromann commented Jan 31, 2018

but I'm still confused which framework to go for.

What am I suppose to say here? I can just recommend to use WebdriverIO. It supports it all.

@sumeetp4

This comment has been minimized.

Show comment
Hide comment
@sumeetp4

sumeetp4 Feb 1, 2018

Okay. Thank you @christian-bromann :)
Do you have any sample code for TouchAction functions?

sumeetp4 commented Feb 1, 2018

Okay. Thank you @christian-bromann :)
Do you have any sample code for TouchAction functions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment