TestArmada / nightwatch-extra

MIT License
30 stars 25 forks source link

Add tests for empty Edge inputs returning a value of null #120

Closed michaeljacobdavis closed 6 years ago

michaeljacobdavis commented 6 years ago

Background

Microsoft Edge was returning null for an empty inputs value property. This led to errors like:

08:26:49 Running: Assert blank fields ...
08:26:50 ✖ TypeError: Cannot read property 'indexOf' of null

A fix to avoid this error was added by https://github.com/TestArmada/nightwatch-extra/pull/108/files.

I added a test for this https://github.com/TestArmada/nightwatch-extra/pull/120/files#diff-e041bab4fb9b10009bf9334cde429064R143

The problem with this fix is is doing client.elValueContains(selector, "") on an empty input will now fail

21:59:04 04:59:00 FAILED:  1 assertions failed (898ms)
21:59:04 04:59:00  _________________________________________________
21:59:04 04:59:00  TEST FAILURE:  1 assertions failed, 0 passed. (22.315s)
21:59:04 04:59:00  ✖ create
21:59:04 04:59:00    - Input project info (898ms)
21:59:04 04:59:00    Testing if selector <#projectName> has value <> after 581 milliseconds  -> Assertion failure   - expected "" but got: ""

I'm feel like that is incorrect and added the test https://github.com/TestArmada/nightwatch-extra/pull/120/files#diff-e041bab4fb9b10009bf9334cde429064R159 to make sure it passes.

Fixing Edge

For browsers returning null for empty inputs, we have no way to consistently test empty fields (since it could be null or "").

We fix this by doing a null check and if true, fixing the actual value to what it should be via the spec https://github.com/TestArmada/nightwatch-extra/pull/120/files#diff-ffe0c41e69cbb1693549935cd322fd51R15

and testing it with https://github.com/TestArmada/nightwatch-extra/pull/120/files#diff-e041bab4fb9b10009bf9334cde429064R149

I'd love some feedback on if I'm missing any edge cases or browser quirks. For non-input elements, value will be undefined so I don't see any false positives that way. Any other cases where the value of an input would be null?

CLAassistant commented 6 years ago

CLA assistant check
All committers have signed the CLA.

michaeljacobdavis commented 6 years ago

@archlichking Looks like the CI for Node v4/5 is failing because of appium-chromedriver using some newer language features.

https://travis-ci.org/TestArmada/nightwatch-extra/jobs/411862132#L1233

archlichking commented 6 years ago

👍 great stuff, thanks for the PR, i'll remove unit test for node@4 and node@5.