SeleniumHQ / selenium-ide

Open Source record and playback test automation for the web.
https://selenium.dev/selenium-ide/
Apache License 2.0
2.78k stars 754 forks source link

Jest Encounterred Unexpected Token Side Runner@ #1587

Open ogomaemmanuel opened 1 year ago

ogomaemmanuel commented 1 year ago

🐛 Jest Encountered Unexcepted Token While Running selenium side Runner

I am running selenium side runner on ubuntu focal image, with node v10-v19 installed, I keep getting above mentioned error, the selenium-side-runner installed is @4.0.0-alpha.37. On my local MacOS machine having node19 installed with the same version of Side runner, the test are passing

To Reproduce

Docker file


FROM ubuntu:focal
USER root
RUN apt update && apt install curl -y

# Install nodejs 10 which includes npm
RUN curl -sL https://deb.nodesource.com/setup_19.x | bash -
RUN apt install nodejs -y
RUN apt install npm -y
RUN node --version
RUN npm install -g selenium-side-runner@4.0.0-alpha.37

# Install python/pip
ENV PYTHONUNBUFFERED=1
RUN apt install python3 -y && ln -sf python3 /usr/bin/python
RUN apt install python3-pip -y
RUN pip3 install --no-cache --upgrade pip setuptools

COPY requirements.txt requirements.txt
RUN  pip3 install -r requirements.txt

COPY google-chrome-stable_current_amd64.deb google-chrome-stable_current_amd64.deb
ENV DEBIAN_FRONTEND=noninteractive
# Chrome dependency Instalation

RUN apt install wget -y

RUN wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb

RUN apt-get  install -y -f ./google-chrome-stable_current_amd64.deb
# RUN  dpkg -i google-chrome-stable_current_amd64.deb

#RUN apt -f install -y
RUN wget https://chromedriver.storage.googleapis.com/100.0.4896.20/chromedriver_linux64.zip

RUN apt install unzip -y
RUN unzip chromedriver_linux64.zip
RUN chmod +x chromedriver
RUN mv chromedriver /usr/bin/chromedriver

RUN groupadd seluser  --gid 1201 \ 
    && useradd seluser  --create-home  --gid 1201 --shell /bin/bash  --uid 1200 \
      && usermod -a -G sudo seluser   \
      && echo 'ALL ALL = (ALL) NOPASSWD: ALL' >> /etc/sudoers   && echo 'seluser:secret' | chpasswd

RUN mkdir /sides && chown -R seluser /sides

RUN mkdir /selenium-side-runner && chown -R seluser /selenium-side-runner
WORKDIR /selenium-side-runner

COPY browser.py browser.py

COPY test.side test.side
RUN chmod +x browser.py
USER seluser
ENTRYPOINT ["python3", "browser.py" ]

Python script

import subprocess
import json
import glob
import os
import boto3
import requests

command = 'selenium-side-runner -c "goog:chromeOptions.args=[--headless,--nogpu] browserName=chrome" --output-directory . *.side'
subprocess.run(command, shell=True, check=False)

json_pattern= os.path.join(".","*.json")
file=glob.glob(json_pattern)[0]
with open(file, "r") as file:
    data = json.load(file)

testResults = data['testResults']
status = data['success']
statusCode = 0 if status==False else 1
#print(postRequest)
print("Passed", testResults)
print("Failed", status)

#exit(0)

Expected behavior

info: Finished test stackoverflow Success
 PASS  ../../../../opt/homebrew/lib/node_modules/selenium-side-runner/dist/main.test.js (48.723 s)
  Running project stackoverflow
    ✓ Running test stackoverflow (48358 ms)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        48.759 s, estimated 58 s
Ran all test suites within paths "/opt/homebrew/lib/node_modules/selenium-side-runner/dist/main.test.js".

Project file reproducing this issue (highly encouraged)

Please provide a project file .side that reproduces this issue.

{
  "id": "8b24d331-17e1-4f60-982c-a5a48b9495ff",
  "version": "2.0",
  "name": "stackoverflow",
  "url": "https://stackoverflow.com",
  "tests": [{
    "id": "3bbfa30f-2800-4dd8-bd33-54b8230550e2",
    "name": "stackoverflow",
    "commands": [{
      "id": "2e19d09e-519c-4b50-a700-7361728558e8",
      "comment": "",
      "command": "open",
      "target": "/",
      "targets": [],
      "value": ""
    }, {
      "id": "4c24fc5d-c535-4259-928b-41d922654789",
      "comment": "",
      "command": "setWindowSize",
      "target": "1200x840",
      "targets": [],
      "value": ""
    }, {
      "id": "be741560-eb36-4bb0-8584-acf7863bac51",
      "comment": "",
      "command": "waitForElementPresent",
      "target": "linkText=Teams",
      "targets": [],
      "value": "30000"
    }, {
      "id": "74fbd303-6ede-4de7-8ca2-2dde5ff121e2",
      "comment": "",
      "command": "click",
      "target": "linkText=Teams",
      "targets": [
        ["linkText=Teams", "linkText"],
        ["css=.site-footer--col:nth-child(2) li:nth-child(1) > .js-gps-track", "css:finder"],
        ["xpath=(//a[contains(text(),'Teams')])[7]", "xpath:link"],
        ["xpath=//footer[@id='footer']/div/nav/div[2]/ul/li/a", "xpath:idRelative"],
        ["xpath=(//a[contains(@href, 'https://stackoverflow.co/teams')])[12]", "xpath:href"],
        ["xpath=//nav/div[2]/ul/li/a", "xpath:position"]
      ],
      "value": ""
    }, {
      "id": "949756d2-230b-4b5a-9da1-c211fb07ad69",
      "comment": "",
      "command": "waitForElementPresent",
      "target": "linkText=Legal",
      "targets": [],
      "value": "30000"
    }, {
      "id": "a5e74b63-46f8-47a1-9a65-0a03d80791fa",
      "comment": "",
      "command": "click",
      "target": "linkText=Legal",
      "targets": [
        ["linkText=Legal", "linkText"],
        ["css=.d-flex:nth-child(3) > .flex--item6:nth-child(1) > .fc-black-400:nth-child(2)", "css:finder"],
        ["xpath=//a[contains(text(),'Legal')]", "xpath:link"],
        ["xpath=//div[@id='__nuxt']/main/footer/div/div/div[3]/div/a", "xpath:idRelative"],
        ["xpath=//a[contains(@href, 'https://stackoverflow.com/legal')]", "xpath:href"],
        ["xpath=//div[3]/div/a", "xpath:position"],
        ["xpath=//a[contains(.,'Legal')]", "xpath:innerText"]
      ],
      "value": ""
    }, {
      "id": "d8c3a2d0-1dbc-41df-9884-9b77619eebfc",
      "comment": "",
      "command": "waitForElementPresent",
      "target": "xpath=(//a[contains(text(),'About')])[3]",
      "targets": [],
      "value": "30000"
    }, {
      "id": "7c47fab1-1f9d-4bf4-bdf4-0c07f489e98b",
      "comment": "",
      "command": "click",
      "target": "xpath=(//a[contains(text(),'About')])[3]",
      "targets": [
        ["css=.site-footer--col:nth-child(3) li:nth-child(1) > .js-gps-track", "css:finder"],
        ["xpath=(//a[contains(text(),'About')])[3]", "xpath:link"],
        ["xpath=//footer[@id='footer']/div/nav/div[3]/ul/li/a", "xpath:idRelative"],
        ["xpath=(//a[contains(@href, 'https://stackoverflow.co/')])[13]", "xpath:href"],
        ["xpath=//div[3]/ul/li/a", "xpath:position"]
      ],
      "value": ""
    }, {
      "id": "70cd2c73-bde7-4b06-9faf-7c827780ea37",
      "comment": "",
      "command": "waitForElementPresent",
      "target": "linkText=Blog",
      "targets": [],
      "value": "30000"
    }, {
      "id": "2afb25f6-8726-4c01-9dca-5c4b7726c045",
      "comment": "",
      "command": "click",
      "target": "linkText=Blog",
      "targets": [
        ["linkText=Blog", "linkText"],
        ["css=.d-flex:nth-child(3) > .flex--item6:nth-child(2) > .fc-black-400:nth-child(2)", "css:finder"],
        ["xpath=//a[contains(text(),'Blog')]", "xpath:link"],
        ["xpath=//div[@id='__nuxt']/main/footer/div/div/div[3]/div[2]/a", "xpath:idRelative"],
        ["xpath=(//a[contains(@href, 'https://stackoverflow.blog/')])[4]", "xpath:href"],
        ["xpath=//div[3]/div[2]/a", "xpath:position"]
      ],
      "value": ""
    }, {
      "id": "f76168ab-be3c-4f16-b45e-6e2603989316",
      "comment": "",
      "command": "waitForElementPresent",
      "target": "linkText=Talent",
      "targets": [],
      "value": "30000"
    }, {
      "id": "bc74de0a-374b-454d-83f7-6a8e0bd30cd2",
      "comment": "",
      "command": "click",
      "target": "linkText=Talent",
      "targets": [
        ["linkText=Talent", "linkText"],
        ["css=.grid__fl1:nth-child(2) > .grid--cell6:nth-child(2) > .fc-black-400:nth-child(5)", "css:finder"],
        ["xpath=//a[contains(text(),'Talent')]", "xpath:link"],
        ["xpath=//div[@id='wrapper']/footer/div/div/div[2]/div[2]/a[4]", "xpath:idRelative"],
        ["xpath=//a[contains(@href, 'https://stackoverflow.co/talent')]", "xpath:href"],
        ["xpath=//div[2]/a[4]", "xpath:position"],
        ["xpath=//a[contains(.,'Talent')]", "xpath:innerText"]
      ],
      "value": ""
    }]
  }],
  "suites": [{
    "id": "eca3add4-3d53-4dfa-80ab-a695d94bf6ae",
    "name": "Default Suite",
    "persistSession": false,
    "parallel": false,
    "timeout": 3000000000,
    "tests": []
  }],
  "urls": ["https://stackoverflow.com/"],
  "plugins": []
}

Issues without a reproduction project are likely to stall.

Environment

OS: Selenium IDE Version: Selenium SIDE Runner Version: Node version: Browser: Browser Version:

toddtarsi commented 1 year ago

@ogomaemmanuel - I am sorry I've taken so long to come back around here. In all honesty, issues like this I try to pretend they don't exist and hope they go away haha. Any luck on that front?