galenframework / galen

Layout and functional testing framework for websites
http://galenframework.com
1.41k stars 163 forks source link

Browser running multiple browsers in Selenium Grid dockerized #546

Open mpluta-airhelp opened 6 years ago

mpluta-airhelp commented 6 years ago

Hello,

Problem I have is to make my test run to use specific browser available inn grid. Even better it should use all browsers that I set in parametrised test. But for now I am running test with command:

docker-compose run --rm -u $(id -u)  galenframework galen test tests/suites/NewHomePage.test --groups STAG -Dbase_url=some_base_url   --htmlreport report -Dbrowser=chrome

and my test looks like this:

@@ table devices
    | deviceName | tags      | size     |
    | Mobile     | mobile    | 360x700  |
    | Tablet     | tablet    | 780x800  |
    | Desktop    | desktop   | 1024x768 |

@@ parameterized using devices
@@ groups EPP, STAG
New homepage on ${deviceName} device ${browser}
    Website Homepage v2017 | ${base_url}test-front-page-2017/ ${size} ${browser}
        wait 3s
        check specs/homepage.gspec --include "${tags}"

Problem is that this command does not override galen.browserFactory.selenium.grid.browser config param and so test is using firefox node:

galen.config:

galen.range.approximation=2
galen.default.browser=chrome
$.webdriver.chrome.driver=/usr/local/bin/chromedriver
spec.colorscheme.precision = 256
galen.browser.screenshots.fullPage.scrollTimeout = 50
galen.browser.screenshots.fullPage.scrollWait = 20
spec.colorscheme.testrange = 6
galen.browserFactory.selenium.runInGrid = true
galen.browserFactory.selenium.grid.url = http://hub:4444/wd/hub
galen.browserFactory.selenium.grid.browser = firefox
galen.test.suffix=.test
galen.test.js.file.suffix=.test.js
galen.browser.pageElement.areaFinder = native

Here is my docker setup:

docker-compose.yml

version: '2'
services:
  galenframework:
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - .:/usr/src/galen
    links:
      - seleniumhub:hub
  seleniumhub:
    image: selenium/hub:3.8.1-aluminum
    ports:
      - "4444"
    environment:
      GRID_TIMEOUT: 0
  chrome_node:
    image: selenium/node-chrome:3.8.1-aluminum
    links:
      - seleniumhub:hub
    ports:
      - "5900"
    environment:
      HUB_PORT_4444_TCP_ADDR: seleniumhub
      HUB_PORT_4444_TCP_PORT: 4444
      SCREEN_WIDTH: 1920
      SCREEN_HEIGHT: 1080
      SCREEN_DEPTH: 24
    shm_size: 1536m
  firefox_node:
    image: selenium/node-firefox:3.8.1-aluminum
    links:
      - seleniumhub:hub
    ports:
      - "5900"
    environment:
      HUB_PORT_4444_TCP_ADDR: seleniumhub
      HUB_PORT_4444_TCP_PORT: 4444
      SCREEN_WIDTH: 1920
      SCREEN_HEIGHT: 1080
      SCREEN_DEPTH: 24
    shm_size: 1536m

and Dockerfile

FROM java:8

ENV NVM_DIR /usr/local/nvm
ENV NODE_VERSION 6.11.4
ENV GALEN_VERSION 2.3.6

# Install nvm with node and npm
RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.31.0/install.sh | bash \
    && . $NVM_DIR/nvm.sh \
    && nvm install $NODE_VERSION \
    && nvm alias default $NODE_VERSION \
    && nvm use default \
    && npm install -g galenframework-cli@$GALEN_VERSION

ENV NODE_PATH      $NVM_DIR/versions/node/v$NODE_VERSION/lib/node_modules
ENV PATH           $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH

RUN mkdir -p /usr/src/galen
WORKDIR /usr/src/galen

Am I missing sth?

Regards! Mateusz

axelbarfod1 commented 6 years ago

Where ou able to make it work ? I'm looking into using grid with Galen but I have been unable to make it work

hypery2k commented 6 years ago

Youncan try my Docker Image https://hub.docker.com/r/galenframework/cli/

mpluta-airhelp commented 6 years ago

@axelbarfod1 - Grid works fine until you need to switch browser. I had no time to look into it recently.

@hypery2k - Can you tell us how you manage cross browser testing?

hypery2k commented 6 years ago

@mplutia-airhelp: Didn't get what you mean. The Docker Image has multiple browsers configured.

mpluta-airhelp commented 6 years ago

@hypery2k how do you set up configuration parameters?:

galen.browserFactory.selenium.runInGrid  
galen.browserFactory.selenium.grid.url 
galen.browserFactory.selenium.grid.browser  

With that setup, what is your command for launching test against given browser? My experience is that there is no such command and browser is taken from galen.config which cannot be changed during runtime. But I might have omitted sth.

Thanks