system-testing 1.0.19 → 1.0.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/system-test.js +12 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "system-testing",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "System testing with Selenium and browsers.",
5
5
  "keywords": [
6
6
  "system",
@@ -7,7 +7,7 @@ import moment from "moment"
7
7
  import {prettify} from "htmlfy"
8
8
  import SystemTestCommunicator from "./system-test-communicator.js"
9
9
  import SystemTestHttpServer from "./system-test-http-server.js"
10
- import {waitFor} from "awaitery"
10
+ import {wait, waitFor} from "awaitery"
11
11
  import {WebSocketServer} from "ws"
12
12
 
13
13
  class ElementNotFoundError extends Error { }
@@ -104,6 +104,10 @@ export default class SystemTest {
104
104
  * @param {import("selenium-webdriver").WebElement} element
105
105
  **/
106
106
  async click(element) {
107
+ if (typeof element == "string") {
108
+ element = await this.find(element)
109
+ }
110
+
107
111
  const actions = this.driver.actions({async: true})
108
112
 
109
113
  await actions.move({origin: element}).click().perform()
@@ -187,6 +191,10 @@ export default class SystemTest {
187
191
  return browserLogs
188
192
  }
189
193
 
194
+ async getCurrentUrl() {
195
+ return await this.driver.getCurrentUrl()
196
+ }
197
+
190
198
  /**
191
199
  * Interacts with an element by calling a method on it with the given arguments.
192
200
  * Retrying on ElementNotInteractableError.
@@ -221,6 +229,8 @@ export default class SystemTest {
221
229
  // Retry finding the element and interacting with it
222
230
  if (tries >= 3) {
223
231
  throw new Error(`${element.constructor.name} ${methodName} failed after ${tries} tries - ${error.constructor.name}: ${error.message}`)
232
+ } else {
233
+ await wait(100)
224
234
  }
225
235
  } else {
226
236
  // Re-throw with un-corrupted stack trace
@@ -521,6 +531,7 @@ export default class SystemTest {
521
531
  await fs.writeFile(logsPath, logsText.join("\n"))
522
532
  await fs.writeFile(screenshotPath, imageContent, "base64")
523
533
 
534
+ console.log("Current URL:", await this.getCurrentUrl())
524
535
  console.log("Logs:", logsPath)
525
536
  console.log("Screenshot:", screenshotPath)
526
537
  console.log("HTML:", htmlPath)