Skip to content

Commit

Permalink
Merge branch 'master' of github.com:Codeception/CodeceptJS
Browse files Browse the repository at this point in the history
  • Loading branch information
DavertMik committed Jun 18, 2020
2 parents adfab76 + df97355 commit d89428a
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 28 deletions.
4 changes: 2 additions & 2 deletions docs/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ I.checkOption('Accept');
I.click('Save');
```

> `selectOption` works only with standard `<select>` <select placeholder="select"></select> HTML elements. If your selectbox is created by React, Vue, or as a component of any other framework, this method potentially won't work with it. Use `click` to manipulate it.
> `selectOption` works only with standard `<select>` <select></select> HTML elements. If your selectbox is created by React, Vue, or as a component of any other framework, this method potentially won't work with it. Use `click` to manipulate it.
> `checkOption` also works only with standard `<input type="checkbox">` <input type="checkbox"> HTML elements. If your checkbox is created by React, Vue, or as a component of any other framework, this method potentially won't work with it. Use `click` to manipulate it.
Expand Down Expand Up @@ -695,7 +695,7 @@ I.say('This is by default'); //cyan is used

## IntelliSense

![](/img/edit.gif)
![Edit](/img/edit.gif)

To get autocompletion when working with CodeceptJS, use Visual Studio Code or another IDE that supports TypeScript Definitions.

Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ I.click('$register_button');
Changed pressKey method to resolve issues and extend functionality.
* Did not properly recognize 'Meta' (or 'Command') as modifier key.
* Right modifier keys did not work in WebDriver using JsonWireProtocol.
* 'Shift' + <key> combination would not reflect actual keyboard behavior.
* 'Shift' + 'key' combination would not reflect actual keyboard behavior.
* Respect sequence with multiple modifier keys passed to pressKey.
* Added support to automatic change operation modifier key based on operating system.
* [Puppeteer][WebDriver] Added `pressKeyUp` and `pressKeyDown` to press and release modifier keys like `Control` or `Shift`. By **[martomo](https://github.com/martomo)**.
Expand Down
2 changes: 1 addition & 1 deletion docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ npx codeceptjs def --config path/to/codecept.json

After doing that IDE should provide autocompletion for `I` object inside `Scenario` and `within` blocks.

Add optional parameter `output` (or shortcat `-o`), if you want to place your definition file in specific folder:
Add optional parameter `output` (or shortcut `-o`), if you want to place your definition file in specific folder:

```sh
npx codeceptjs def --output ./tests/typings
Expand Down
6 changes: 3 additions & 3 deletions docs/detox.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ If element differs on on iOS and Android you can use **cross platform locators**
```js
// locate element by text on Android
// locate element by accessibility id on iOS
I.click({ andropermalink: /'Start', ios: '~start' });
I.click({ android: /'Start', ios: '~start' });
```

When application behavior differs on Android and iOS use platform-specific actions:
Expand Down Expand Up @@ -207,7 +207,7 @@ Scenario('save in application', (I) => {
I.fillField('#text', 'a new text');
I.see('a new text', '#textValue');
I.dontSeeElement('#createdAndVisibleText');
I.click({ ios: '#GoButton', andropermalink: /'Button' });
I.click({ ios: '#GoButton', android: /'Button' });
I.waitForElement('#createdAndVisibleText', 20);
I.seeElement('#createdAndVisibleText');
I.runOnAndroid(() => {
Expand All @@ -232,4 +232,4 @@ If you want to use detox configuration other than is set in `codecept.conf.js` u
npx codeceptjs run --configuration android.test.ci
```

You can also pass all [other arguments that Detox CLI supports](https://github.com/wix/Detox/blob/master/docs/APIRef.DetoxCLI.md#test).
You can also pass all [other arguments that Detox CLI supports](https://github.com/wix/Detox/blob/master/docs/APIRef.DetoxCLI.md#test).
4 changes: 2 additions & 2 deletions docs/mobile-react-native-locators.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ You could do it just by changing `automationName` in the `helpers` section of th
```
Then you could locate components using XPath expression:
```js
I.tap({andropermalink: /'//*[@view-tag="someButton"]', ios: '~someButton'})
I.tap({android: /'//*[@view-tag="someButton"]', ios: '~someButton'})
```
This way test would work for both platforms without any changes in code.
To simplify things further you could write a helper function:
```js
function tid(id) {
return {
andropermalink: /`//*[@view-tag="${id}"]`,
android: /`//*[@view-tag="${id}"]`,
ios: '~' + id
}
}
Expand Down
4 changes: 2 additions & 2 deletions docs/mobile.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ I.see('[email protected]', '~email of the customer'));
I.clearField('~email of the customer'));
I.dontSee('Nothing special', '~email of the customer'));
I.seeElement({
andropermalink: /'android.widget.Button',
android: /'android.widget.Button',
ios: '//UIAApplication[1]/UIAWindow[1]/UIAButton[1]'
});
```
Expand Down Expand Up @@ -262,7 +262,7 @@ It is often happen that mobile applications behave similarly on different platfo
CodeceptJS provides a way to specify different locators for Android and iOS platforms:
```js
I.click({andropermalink: /'//android.widget.Button', ios: '//UIAApplication[1]/UIAWindow[1]/UIAButton[1]'});
I.click({android: /'//android.widget.Button', ios: '//UIAApplication[1]/UIAWindow[1]/UIAButton[1]'});
```

In case some code should be executed on one platform and ignored on others use `runOnAndroid` and `runOnIOS` methods:
Expand Down
6 changes: 1 addition & 5 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,7 @@ This gives you access to rich Selenium ecosystem and cross-browser support for m

<a href="/webdriver" class="button extended" >Start with WebDriver &raquo;</a>

<small>

WebDriver support is implemented via [webdriverio](https://webdriver.io) library

</small>
<small> WebDriver support is implemented via [webdriverio](https://webdriver.io) library </small>

---

Expand Down
2 changes: 1 addition & 1 deletion docs/testcafe.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ title: Testing with TestCafe

[TestCafe](https://devexpress.github.io/testcafe/) is another alternative engine for driving browsers. It is driven by unique technology which provides fast and simple cross browser testing for desktop and mobile browsers. Unlike WebDriver or Puppeteer, TestCafe doesn't control a browser at all. It is not a browser itself, like [Nightmare](/nightmare) or Cypress. **TestCafe core is a proxy server** that runs behind the scene, and transforms all HTML and JS to include code that is needed for test automation.

![](/img/testcafe.png)
![Testcafe](/img/testcafe.png)

This is very smart idea. But to use TestCafe on daily basis you need to clearly understand its benefits and limitations:

Expand Down
2 changes: 1 addition & 1 deletion docs/ui.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ permalink: /ui
---


<img src="/img/codeceptui.png" style="width: 100%; border-radius: 5px; box-shadow: 0px 5px 10px rgba(0,0,0,0.1)" />
<img src="/img/codeceptui.png" alt="CodeceptUI" style="width: 100%; border-radius: 5px; box-shadow: 0px 5px 10px rgba(0,0,0,0.1)" />


## CodeceptUI <Badge text="beta" type="warn"/>
Expand Down
2 changes: 1 addition & 1 deletion docs/videos.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ editLink: false
---

> Add your own videos to our [Wiki Page](https://github.com/Codeception/CodeceptJS/wiki/Videos)
[![](http://i3.ytimg.com/vi/BRMWstiOTks/maxresdefault.jpg)](https://www.youtube.com/watch?v=BRMWstiOTks)
[![Maxresdefault](http://i3.ytimg.com/vi/BRMWstiOTks/maxresdefault.jpg)](https://www.youtube.com/watch?v=BRMWstiOTks)

* ## [An Introduction, Getting started and working with CodeceptJS & Puppeteer (EAWeekend)](https://www.youtube.com/watch?v=BRMWstiOTks)

Expand Down
2 changes: 1 addition & 1 deletion lib/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ module.exports = function (obj) {
/**
* add print comment method`
* @param {string} msg
* @param {string} color
* @param {string} [color]
* @return {Promise<any> | undefined}
* @inner
*/
Expand Down
15 changes: 10 additions & 5 deletions lib/helper/Appium.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,6 @@ class Appium extends Webdriver {
return `${protocol}://${hostname}:${port}${path}`;
}


/**
* Execute code only on iOS
*
Expand Down Expand Up @@ -430,7 +429,6 @@ class Appium extends Webdriver {
fn();
}


/**
* Check if an app is installed.
*
Expand Down Expand Up @@ -1319,7 +1317,6 @@ class Appium extends Webdriver {
return super.dontSeeInField(parseLocator.call(this, field), value);
}


/**
* {{> dontSee }}
*/
Expand Down Expand Up @@ -1457,7 +1454,11 @@ function parseLocator(locator) {
}

if (locator.android && this.platform === 'android') {
return parseLocator.call(this, locator.android);
if (typeof locator.android === 'string') {
return parseLocator.call(this, locator.android);
}
// The locator is an Android DataMatcher or ViewMatcher locator so return as is
return locator.android;
}

if (locator.ios && this.platform === 'ios') {
Expand All @@ -1472,8 +1473,12 @@ function parseLocator(locator) {
// hook before webdriverio supports native # locators
return parseLocator.call(this, { id: locator.slice(1) });
}

if (this.platform === 'android' && !this.isWeb) {
return `android=new UiSelector().text("${locator}")`;
const isNativeLocator = /^\-?android=?/.exec(locator);
return isNativeLocator
? locator
: `android=new UiSelector().text("${locator}")`;
}
}

Expand Down
28 changes: 25 additions & 3 deletions test/unit/utils_test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const assert = require('assert');
const os = require('os');
const path = require('path');
const sinon = require('sinon');

const utils = require('../../lib/utils');
Expand Down Expand Up @@ -307,12 +308,33 @@ describe('utils', () => {

it('returns the joined filename for filename only', () => {
const _path = utils.screenshotOutputFolder('screenshot1.failed.png');
_path.should.eql('/Users/someuser/workbase/project1/test_output/screenshot1.failed.png');
_path.should.eql(
'/Users/someuser/workbase/project1/test_output/screenshot1.failed.png'.replace(
/\//g,
path.sep,
),
);
});

it('returns the given filename for absolute one', () => {
const _path = utils.screenshotOutputFolder('/Users/someuser/workbase/project1/test_output/screenshot1.failed.png');
_path.should.eql('/Users/someuser/workbase/project1/test_output/screenshot1.failed.png');
const _path = utils.screenshotOutputFolder(
'/Users/someuser/workbase/project1/test_output/screenshot1.failed.png'.replace(
/\//g,
path.sep,
),
);
if (os.platform() === 'win32') {
_path.should.eql(
path.resolve(
global.codecept_dir,
'/Users/someuser/workbase/project1/test_output/screenshot1.failed.png',
),
);
} else {
_path.should.eql(
'/Users/someuser/workbase/project1/test_output/screenshot1.failed.png',
);
}
});
});
});

0 comments on commit d89428a

Please sign in to comment.