Closed AdrienLemaire closed 5 years ago
Problem fixed. I had an error in my onReadyScript (By.class()
→ By.className()
), which failed all actions in the preSnapshootSetup including removeElements.
It might be a good idea to add links to the usage documentation of the By and browser variables available in the onReadyScript. the async/await syntax doesn't cause any problem, so the sentence about transpiling could also be reworded/removed
Hi, I setup ayespy and could generate screenshots with it, but I'm facing a couple issues:
For the element to remove, are you waiting for the element to be available before trying to remove it? This doesn't seem to be the case, and I'm wondering why (backstopjs does wait for the element before removing it).
For the script, that is never entered, might it be because it's es6-7 syntax and not transpiled as recommended? Can you give either a bare minimal command to transpile, or a default example in es5? I quickly tried to transpile with babel without success (not running a js project, and not wanting to setup webpack or equivalent for that).
screenshots
![](https://i.imgur.com/CTPHhm7.png) ![](https://i.imgur.com/OcFkIkM.png)ayespy-config.json
```console npm ls -g /usr/lib ├─┬ aye-spy@4.5.1 │ ├─┬ aws-sdk@2.493.0 │ │ ├─┬ buffer@4.9.1 │ │ │ ├── base64-js@1.3.0 │ │ │ ├── ieee754@1.1.8 deduped │ │ │ └── isarray@1.0.0 │ │ ├── events@1.1.1 │ │ ├── ieee754@1.1.8 │ │ ├── jmespath@0.15.0 │ │ ├── querystring@0.2.0 │ │ ├── sax@1.2.1 │ │ ├─┬ url@0.10.3 │ │ │ ├── punycode@1.3.2 │ │ │ └── querystring@0.2.0 deduped │ │ ├── uuid@3.3.2 │ │ └─┬ xml2js@0.4.19 │ │ ├── sax@1.2.1 deduped │ │ └── xmlbuilder@9.0.7 ``` ```json { "gridUrl": "http://company-lab.local:4444/wd/hub", "baseline": "./regression_tests/baseline", "latest": "./regression_tests/latest", "generatedDiffs": "./regression_tests/generated_diffs", "report": "./regression_tests/report", "scenarios": [ { "url": "http://company-lab.local:8000/%E7%A6%-%E7%95%A3%AB/", "label": "user profile", "removeElements": ["#djDebug"], "hideElements": ["#djDebug"], "viewports": [ { "height": 800, "width": 1280, "label": "xl-max" } ], "waitForElement": "#djDebug", "onReadyScript": "./regression_tests/scripts/clickTable.js", "wait": 1000 } ] } ```regression_tests/scripts/clickTable.js
```js // https://github.com/newsuk/ayespy#on-ready-script async function clickTable (browser, By) { //debugger; //await browser.wait(until.elementIsVisible(browser.findElement(By.css(utils.getFirstName()))), 10000); await browser.findElement(By.class("point_totals_table")).click(); }; module.exports = clickTable; ```Chrome docker logs
``` chrome | 21:22:38.226 INFO [ActiveSessionFactory.apply] - Capabilities are: { chrome | "browserName": "chrome", chrome | "goog:chromeOptions": { chrome | } chrome | } chrome | 21:22:38.228 INFO [ActiveSessionFactory.lambda$apply$11] - Matched fact ory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa .se) chrome | Starting ChromeDriver 2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7cc 44e5) on port 32389 chrome | Only local connections are allowed. chrome | [1563398558.262][SEVERE]: bind() failed: Cannot assign requested addres s (99) chrome | 21:22:38.833 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS chrome | 21:22:39.110 INFO [RemoteSession$Factory.lambda$performHandshake$0] - S tarted new session d24a75d753c86ad022f890b2f7820de5 (org.openqa.selenium.chrome.ChromeDri ver) chrome | 21:22:45.744 INFO [ActiveSessions$1.onStop] - Removing session d24a75d7 53c86ad022f890b2f7820de5 (org.openqa.selenium.chrome.ChromeDriverService) chrome | 21:27:55.539 INFO [ActiveSessionFactory.apply] - Capabilities are: { chrome | "browserName": "chrome", chrome | "goog:chromeOptions": { chrome | } chrome | } chrome | 21:27:55.539 INFO [ActiveSessionFactory.lambda$apply$11] - Matched fac) chrome | Starting ChromeDriver 2.45.615279 (12b89733300bd268cff3b78fc76cb8f3a7c7 chrome | Only local connections are allowed. chrome | [1563398875.563][SEVERE]: bind() failed: Cannot assign requested addre) chrome | 21:27:56.033 INFO [ProtocolHandshake.createSession] - Detected dialectS chrome | 21:27:56.114 INFO [RemoteSession$Factory.lambda$performHandshake$0] - ) ```transpiling attempt with babel
```console $ npm install --save-dev @babel/core @babel/cli @babel/preset-env $ npm install --save @babel/polyfill $ vim babel.config.js # https://babeljs.io/docs/en/usage#overview $ ./node_modules/.bin/babel block_report/regression_tests/scripts/clickTable.js --out-dir lib Successfully compiled 1 file with Babel. $ cat lib/clickTable.js # NO CHANGE "use strict"; // https://github.com/newsuk/ayespy#on-ready-script async function clickTable(browser, By) { debugger; //await browser.wait(until.elementIsVisible(browser.findElement(By.css(utils.getFirstName()))), 10000); await browser.findElement(By.class("point_totals_table")).click(); } ; module.exports = clickTable; ```