10

I am running a combination of Node.js + Mocha + Selenium Webdriverjs for the first time. I setup everything according to their documentation here https://code.google.com/p/selenium/wiki/WebDriverJs, but I find it very difficult to actually find a list of all the commands available via the web driver. Is there a list of commands that are available to use when writing tests using Selenium webdriverjs?

For example how would I achieve the below java code using Javascript

new Wait("Couldn't find close button!") {
  boolean until() {
    return selenium.isElementPresent("button_Close");
  }
};

I know I can use driver.wait but it doesn't recognize the until command or the isElementPresent

Dan
  • 981
  • 2
  • 12
  • 24

3 Answers3

8

I look here directly at the source file for docs. It's actually pretty good:

https://code.google.com/p/selenium/source/browse/javascript/webdriver/webdriver.js

In answer to your question, you don't really want to wait in WebDriverJS, you want to get used to the deferred objects and promises api. I've just written a blog post about it here that should help you:

http://xolv.io/blog/2013/04/end-to-end-testing-for-web-apps-meteor

nilesh
  • 14,131
  • 7
  • 65
  • 79
Xolv.io
  • 2,483
  • 1
  • 15
  • 17
  • That blog link is now out of date. The correct link is: http://xolv.io/blog-posts/2013/04/end-to-end-testing-for-web-apps-meteor – Alister Scott Dec 29 '15 at 00:03
0

I was looking through the source code as well. They have a compiled version of the API docs that is a bit easier to scan through here:

http://selenium.googlecode.com/git/docs/api/javascript/module_selenium-webdriver.html

Unfortunately, there is no summary with just the method names. You still have to scroll through the page.

In terms of how to wait:

webdriver = require 'selenium-webdriver'
driver = ... // init your driver

driver.wait(webdriver.until...)
Brennan Cheung
  • 4,271
  • 4
  • 30
  • 29
0

@op, its best you use a chained statement. I use the until and isElementPresent command, and they work for production ready (CI/CD) train processes. Tweaking your code thus should work

var isDisplayed = function(){
        driver.isElementPresent(by.id('button id')).then(function(isDisplayed){
            expect(isDisplayed).to.be.true
        });
    }; 
Kermit_ice_tea
  • 508
  • 2
  • 8
  • 16