gemini-testing / gemini

💀💀💀[DEPRECATED] Use hermione
https://github.com/gemini-testing/hermione
MIT License
1.5k stars 149 forks source link

ExecuteJS doesnt work with arrow function #953

Closed ghost closed 5 years ago

ghost commented 5 years ago

gemini --version: 7.1.2 ... Hello. I try to hide scrollbar.

Test source code:

/* global gemini */
const urlList = require('./url-list');

urlList.forEach((url) => {
    gemini.suite(url + '-burger', (suite) => {
        suite
            .setUrl(url + '.html#mobile-menu')
            .before((actions) =>{
                actions.executeJS(() => {
                    const style = document.createElement('style');
                    const head = document.querySelector('head');
                    const scrollBarStyle = document.createTextNode('::-webkit-scrollbar {display: none;}');
                    head.appendChild(style);
                    style.appendChild(scrollBarStyle);
                });
            })
            .setCaptureElements('html')
            .capture('plain');
    });
});

I ger error:

[execute("(() => {\n\t\t\t\t\tlet style = document.createElement('style');\n\t\t\t\t\tlet head = document.querySelector('head');\n\t\t\t\t\tlet scrollBarStyle = document.createTextNode('::-webkit-scrollbar {display: none;}');\n\t\t\t\t\thead.appendChild(style);\n\t\t\t\t\tstyle.appendChild(scrollBarStyle);\n\t\t\t\t}(window));")] Error response status: 13, , UnknownError - An unknown server-side error occurred while processing the command. Selenium error: unknown error: Runtime.evaluate threw exception: SyntaxError: Unexpected token (
  (Session info: headless chrome=71.0.3578.98)
  (Driver info: chromedriver=2.43.600229 (3fae4d0cda5334b4f533bede5a4787f7b832d052),platform=Mac OS X 10.14.2 x86_64)

But this code works properly:

/* global gemini */
const urlList = require('./url-list');

urlList.forEach((url) => {
    gemini.suite(url + '-burger', (suite) => {
        suite
            .setUrl(url + '.html#mobile-menu')
            .before((actions) =>{
                actions.executeJS(function() {
                    let style = document.createElement('style');
                    let head = document.querySelector('head');
                    let scrollBarStyle = document.createTextNode('::-webkit-scrollbar {display: none;}');
                    head.appendChild(style);
                    style.appendChild(scrollBarStyle);
                });
            })
            .setCaptureElements('html')
            .capture('plain');
    });
});

What am I doing wrong?

j0tunn commented 5 years ago

Hi. Which browser do you test?

ghost commented 5 years ago

Hi. Which browser do you test?

chrome=71.0.3578.98 chromedriver=2.43.600229

masi commented 5 years ago

Happens for me too with a Chromium 72.0.3626.121-r0 using Alpine 3.9.2.