@camperaid/watest 2.5.6 → 2.5.7

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camperaid/watest",
3
- "version": "2.5.6",
3
+ "version": "2.5.7",
4
4
  "description": "Web Application Testsuite",
5
5
  "type": "module",
6
6
  "engines": {
@@ -44,6 +44,10 @@ function getChromeOptions() {
44
44
  chromeOptions.addArguments('no-sandbox');
45
45
  chromeOptions.addArguments('disable-dev-shm-usage');
46
46
 
47
+ // Disable disk cache so stale resources from previous deploys are never
48
+ // served from cache. Each test session fetches everything from the network.
49
+ chromeOptions.addArguments('disk-cache-size=0');
50
+
47
51
  for (const arg of settings.webdriver_chrome_args || []) {
48
52
  chromeOptions.addArguments(arg);
49
53
  }
@@ -580,15 +584,43 @@ class DriverBase {
580
584
  });
581
585
  `;
582
586
 
587
+ // Removes listeners and cleans up globals without waiting for a click
588
+ // event. Used when no_click_check is set and the click may not fire
589
+ // standard mouse events (e.g. range inputs on mobile Chrome).
590
+ let cleanupClick = `
591
+ const events = ['mousedown', 'mouseup', 'click', 'dblclick'];
592
+ for (let ev of events) {
593
+ window.document.removeEventListener(
594
+ ev, window.__selenium_clickHandler, true
595
+ );
596
+ }
597
+ delete window.__selenium_clickHandler;
598
+ delete window.__selenium_lastClick;
599
+ delete window.__selenium_clickElRect;
600
+ (arguments[arguments.length - 1])();
601
+ `;
602
+
583
603
  return this.waitForElementToInvoke(
584
604
  selector,
585
605
  el =>
586
606
  this.dvr
587
607
  .executeAsyncScript(listenClick, selector)
588
608
  .then(() => click_func(el))
589
- .then(
590
- () => !no_click_check && this.dvr.executeAsyncScript(checkClick),
591
- )
609
+ .then(() => {
610
+ let p = this.dvr.executeAsyncScript(
611
+ no_click_check ? cleanupClick : checkClick,
612
+ );
613
+ if (no_click_check) {
614
+ // Page may navigate before cleanup script runs - that's OK.
615
+ p = p.catch(e => {
616
+ if (e instanceof error.ScriptTimeoutError) {
617
+ return null;
618
+ }
619
+ throw e;
620
+ });
621
+ }
622
+ return p;
623
+ })
592
624
  .then(r => {
593
625
  if (!r) {
594
626
  if (!no_click_check) {