Skip to content

moveTo doesn't take null in first parameter, but should do it according to documentation #3404

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

Closed
AlexanderGulakov opened this issue Sep 22, 2022 · 0 comments · Fixed by #3427
Assignees

Comments

@AlexanderGulakov
Copy link

AlexanderGulakov commented Sep 22, 2022

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch nightwatch@2.3.7 for the project I'm working on.

my test:
var agentName = process.env.AGENT_NAME;
var agentSession = Number(process.env.SESSION_IDX);
var agentSessionName = process.env.SESSION_NAME;
var agentNumber = process.env.AGENT_NUM;

client.include("SetTestExpectation_alert")

client.rtcEvent("Start", 'global')
.rtcProgress("Start")
.pause(agentNumber * 500);
var sec = 1000;
var roomUrl = "some_roomUrl"

client
.rtcInfo("process.env.RTC_RUN_COUNT " + process.env.RTC_RUN_COUNT)
.rtcInfo("RTC agent start - agent: %s room: %s", agentName, roomUrl)
.url(roomUrl)
.waitForElementVisible('#input-user-name', 120 * sec)
.pause(300) //wait for page render
.setValue('#input-user-name', agentName.replace(/-/g, ''))
.pause(300)
.click(".MuiButtonBase-root.MuiButton-root")
.pause(5000)
.useXpath()
.waitForElementVisible("//[text()='Join Now']", 120 * sec)
.pause(300)
.click("//
[text()='Join Now']")
.rtcProgress("In " + roomUrl)

client
.rtcSetNetwork({
outgoing: {
packetloss: 5,
jitter: 50,
latency: 200,
bitrate: 5000
},
incoming: {
packetloss: 6,
jitter: 50,
latency: 200,
bitrate: 6000
}
});

client
.pause(30 * sec)
.useCss()
.moveTo(null, 110, 10)
.pause(30 * sec)

client
.useXpath()
.waitForElementVisible("//[text()='Disconnect']", 60 * sec)
.pause(300)
.click("//
[text()='Disconnect']")
.pause(15 * sec)

LOGS:

→ Running command: moveTo (, 110, 10)

→ Error
Error while running .moveTo() protocol action: Unknown element: null

-->

Here is the diff that solved my problem:

index 83efe39..b63991e 100644
--- a/node_modules/nightwatch/lib/transport/selenium-webdriver/method-mappings.js
+++ b/node_modules/nightwatch/lib/transport/selenium-webdriver/method-mappings.js
@@ -1,6 +1,6 @@
 const {WebElement, Origin, By} = require('selenium-webdriver');
 const {Locator} = require('../../element');
-const {isString} = require('../../utils');
+const {isString,isNull} = require('../../utils');
 const fs = require('fs');
 const cdp = require('./cdp.js');
 
@@ -26,6 +26,10 @@ module.exports = class MethodMappings {
       return new WebElement(this.driver, webElementOrString);
     }
 
+    if (isNull(webElementOrString)) {
+      return new WebElement(this.driver, '');
+    }
+
     throw new Error(`Unknown element: ${webElementOrString}`);
   }
 
diff --git a/node_modules/nightwatch/lib/utils/index.js b/node_modules/nightwatch/lib/utils/index.js
index 18d1f35..63ad935 100644
--- a/node_modules/nightwatch/lib/utils/index.js
+++ b/node_modules/nightwatch/lib/utils/index.js
@@ -32,7 +32,8 @@ const PrimitiveTypes = {
   BOOLEAN: 'boolean',
   NUMBER: 'number',
   STRING: 'string',
-  UNDEFINED: 'undefined'
+  UNDEFINED: 'undefined',
+  NULL: null
 };
 
 class Utils {
@@ -72,6 +73,10 @@ class Utils {
     return !Utils.isUndefined(value);
   }
 
+  static isNull(value) {
+    return value === PrimitiveTypes.NULL;
+  }
+  
   static isES6AsyncFn(fn) {
     return Utils.isFunction(fn) && fn.constructor.name === 'AsyncFunction';
   }

This issue body was partially generated by patch-package.

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

Successfully merging a pull request may close this issue.

3 participants