GithubHelp home page GithubHelp logo

nightwatch-commands's People

Contributors

afgoulart avatar ellenmobify avatar johnboxall avatar kbingman avatar lilyzh avatar scalvert avatar walkerdb 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

Watchers

 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

nightwatch-commands's Issues

Check for selenium-server.jar and chromedriver binary before downloading

Summary

When installing nightwatch-commands, a copy of selenium-server.jar and a chromedriver binary are downloaded as well. If these files already exist, perhaps we don't need to redownload every time.

Expected behaviour

To save time and bandwidth, don't download selenium-server and chromedriver binary if they already exist locally.

Actual behaviour

Download every time.

Steps to reproduce

  1. In package.json, use a different version of nightwatch-commands
  2. npm install
  3. selenium-server and chromedriver are downloaded even though a local copy of the same version already exists

The command "navigate" is already defined

Summary

I get the following error

Error: The command "navigate" is already defined!

when adding

"custom_commands_path": "./node_modules/nightwatch-commands/commands",

to my config.

Is suspect it collides with the core navigate command introduced here.

Expected behaviour

Nightwatch doesn't throw an error when adding commands to custom_commands_path

Actual behaviour

Throws an error

Error: The command "navigate" is already defined!

Steps to reproduce

npm install nightwatch-commands --save-dev

Add to nightwatch.json

 "custom_commands_path": "./node_modules/nightwatch-commands/commands",

Run nightwatch

nightwatch-commands support for nightwatch v1

Summary

nightwatch-commands support for nightwatch v1
I tried integrating the nightwatch-commands package with nightwatch (version 1.2.1) and I am getting the below issue.

@ellenmobify - It will be greatly appreciated if you can look at this issue.

Console Error Log

λ npm run chrome

> [email protected] chrome C:\Users\sthoma40\MyDocs\Officeworks\Automation\nightwatchjs-selenium-example
> nightwatch -e chrome


[Github] Test Suite
===================
Running:  Demo test GitHub

   TypeError: Error while running "waitForCondition" command: "TypeError: Class constructor ProtocolActions cannot be invoked without 'new'
  "


FAILED: 1 errors (1.355s)
   TypeError: Error while running "waitForCondition" command: "TypeError: Class constructor ProtocolActions cannot be invoked without 'new'
  "

github.js

module.exports = {
  tags: ['git'],
  'Demo test GitHub': function (client) {
    client
      .url('https://github.com/nightwatchjs/nightwatch')
      .waitForAjaxCompleted()
      .waitForElementVisible('body', 1000)
      .getTitle(function (result) {
        client.assert.equal(result.indexOf('GitHub - nightwatchjs/nightwatch'), 0, 'Page title starts with nightwatch')
      })
      .assert.visible('.container h1 strong a')
      .assert.containsText('.container h1 strong a', 'nightwatch', 'Checking project title is set to nightwatch');
  },

  after: function (client) {
    client.end();
  }
};

nightwatch.conf.js

module.exports = {
  src_folders: ['tests'],
  output_folder: 'output/reports',
  custom_commands_path: './node_modules/nightwatch-commands/commands',
  custom_assertions_path: '',
  page_objects_path: '',

Package.json

  "devDependencies": {
    "chromedriver": "^75.1.0",
    "edgedriver": "^4.17134.1",
    "geckodriver": "^1.16.2",
    "iedriver": "^3.14.1",
    "nightwatch": "^1.2.1",
    "nightwatch-commands": "^3.0.0",
    "selenium-server": "^3.141.59"
  }

What's the best way to pass arguments to `condition` in the `waitForCondition` command?

For example, in a condition like this I want to pass the selector argument:

const condition = (selector) => {
  return !! $(selector).attr('disabled')
}

But it looks like there is no way to do this except of constructing condition as string:

// like this
const condition = `return !! $(${selector}).attr('disabled')`

// or this
const conditionFunc = () => {
  return !! $({{SELECTOR}}).attr('disabled')
}

const condition = conditionFunc.toString().replace('{{SELECTOR}}', selector)

Not a big deal in the exampe, but there might be really big condition functions where such constructing can really bother.

Wouldn't it be as simple to add support for arguments as to add the extra argument for the execute call here?

this.protocol.execute.call(this.client, this.condition, function(result) {
var now = new Date().getTime();
if (result.status === 0 && result.value !== 'undefined') {
setTimeout(function() {
var msg = self.messages.success + (now - self.startTimer) + ' milliseconds.';
self.cb.call(self.client.api, result.value);
self.client.assertion(true, !!result.value, false, msg, true);
return self.emit('complete');
}, self.timeout);
} else if (now - self.startTimer < self.ms) {
setTimeout(function() {
self.check();
}, 500);
} else {
var msg = self.messages.timeout + self.ms + ' milliseconds.';
self.cb.call(self.client.api, false);
self.client.assertion(false, false, false, msg, true);
return self.emit('complete');
}
});

Extend site.json to accept multiple profiles

We need to be able to specify multiple site profiles in the site.json file.

Example:

{
  activeProfile: "en";
  profiles: [
    "en" : {
      "bundleUrl": ""
    },
    "fr": {
       "bundleUrl": ""
    }
  ];
}

Production flag

We need the ability to set a flag to production, so that browser.preview() will just get whatever URL is set in the site.json file.

example:

site.json:
{
"bundleUrl": "bundle location",
"siteUrl": "http://www.customer.com"
"production": "true"
}

header.js
module.exports = {
'setUp': function(browser) {
//because production set to true, preview defaults to .get("http://www.customer.com")
browser.preview();
},

Update Selenium server, Chrome driver

Our conf currently:

// see http://selenium-release.storage.googleapis.com/index.html for latest
var seleniumVersion = '2.40.0';

// see http://chromedriver.storage.googleapis.com/index.html
var chromeDriverVersion = '2.9';

Latest versions are 2.45.0 and 2.15, respectively.

Updating will require the following fixes:

browser.getAttribute('<selector>', 'value', function(result) {
  ...
});

Add if/else logic for page elements

We could really use if/else logic functions for presence/visibility of page elements. This would allow us to set up tests with conditional checks and adjust the test accordingly. For example, to check whether a "Sold out"-type element is present, and divert an Add-to-cart flow to add a different, non-sold-out item.

Possible commands could be:
ifElementExists(selector)
ifElementNotExists(selector)
ifElementVisible(selector)
ifElementHidden(selector)

A possible test flow using a command could be of the form:

ifElementExists(selector) {
    do foo
} else {
    do bar
}

Add a swipe command

We really need a swipe command to test gestures on page elements (swipe through carousels, etc).

Potential arguments could include:

  • Origin point (be it specified through CSS selector or pixel position)
  • Direction to swipe
  • How many pixels to swipe before touch release
  • A perpendicular variation factor to include in the swipe gesture (No one can swipe perfectly straight. This could be a pixel factor that 'fudges' the swipe to make it realistic)

Error when trying to use waitUntilMobified()

I try to use waitUntilMobified() to wait for my new page to be loaded, but when I use it in my test I get the following error:

Error while running waitForCondition command: Cannot find module 'nightwatch/lib/api/protocol.js'

New Command: attributeContains

currently I am unable to determine if the value of an attribute contains "/images/myImage.png" as image paths change for environments I would like to use contains rather than equals.

example would be:
.verify.attributeContains(selectors.headerLogo + ' img', 'src', '/images/myImage.png')

Error when running tests

Hello,

When I execute npm test I get the following error on some tests:

Error: Cannot find module '/home/andregoulart/projetos/nightwatch-commands/tests/tests/system/site.json'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/home/andregoulart/projetos/nightwatch-commands/commands/preview.js:29:12)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)

Does anyone else get this problem? It seems there's no .../tests/system/site.json file.

Thanks in advance!

Package complains about site.js or something

Summary

I'm using thie package solely for waitForAjaxCompleted and it outputs a warning or something that I'm not using site.js.

Expected behaviour

Package should not output anything that's unrelated to actual commands the developer is using

Actual behaviour

Package warns about something

Steps to reproduce

Install and enable the package, then run a test

TypeError: Cannot read property 'undefined' of undefined

Issue when running nightwatch tests using latest master code from nightwatch-commands

Error in terminal reads:
TypeError: Cannot read property 'undefined' of undefined
at Object. (/Users/Marlow/Development/Mobifyjs-coasthotels-mobile/node_modules/nightwatch-commands/commands/preview.js:32:21)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at /Users/Marlow/Development/Mobifyjs-coasthotels-mobile/node_modules/nightwatch/lib/core/api.js:247:29
at Array.forEach (native)
at loadCustomCommands (/Users/Marlow/Development/Mobifyjs-coasthotels-mobile/node_modules/nightwatch/lib/core/api.js:245:18)

I have performed a workaround by rolling back my local master to before the last PR was merged, and created a new "rollback" branch with which to rollback my nightwatch-commands in my nightwatch tests (inside of package.json: "nightwatch-commands": "git+https://github.com/mobify/nightwatch-commands.git#rollback").

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.