Karate: How to run Karate UI tests with Github Actions?

99 views Asked by At

Working with UI tests and i need to run tests with Gradle using Github Actions, Karate API test works fine, but UI doesn't. My configs here

          - uses: browser-actions/setup-chrome@v1
        with:
          chrome-version: 114
      - uses: actions/checkout@v2
      - uses: nanasess/setup-chromedriver@v2
        with:
          chromedriver-version: '114.0.5735.90'
      - run: |
          export DISPLAY=:99
          chromedriver --url-base=/wd/hub &
          sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 &
* configure driver = { type: 'chrome', headless: true, showDriverLog: true, addOptions: [ '--headless=new'] }

Looks like the test see driver and works, but fails at random point everytime

Scenario:
    Given driver baseUrl + 'registration/'

#   Testing of firstName field
    And input("//*[@id='firstName']",'')
    When click("//*[@id='content']/div/form/div[2]/button")
    Then waitFor("//*[@id='content']/div/form/div[1]/div[2]/div[1]/small")
>>> failed features:
js failed:
>>>>
01: input("//*[@id='firstName']",'')
<<<<
org.graalvm.polyglot.PolyglotException: js eval failed twice:var e = document.evaluate("//*[@id='firstName']", document, null, 9, null).singleNodeValue; e.focus(); try { e.selectionStart = e.selectionEnd = e.value.length } catch(x) {}, error: [type: MAP, value: {type=object, subtype=error, className=TypeError, description=TypeError: Cannot read properties of null (reading 'focus')
    at <anonymous>:1:95, objectId=-212886562775524013.1.3}]
- com.intuit.karate.driver.DevToolsDriver.evalInternal(DevToolsDriver.java:358)
- com.intuit.karate.driver.DevToolsDriver.eval(DevToolsDriver.java:322)
- com.intuit.karate.driver.DevToolsDriver.input(DevToolsDriver.java:636)
- <js>.:anonymous(Unnamed:1)
15:08:08.649 [main]  WARN  c.intuit.karate.driver.DriverOptions - js eval failed once:(function(){ var fun = function(_){ return _.textContent.includes('[email protected]') }; var e = document.evaluate("/html/body/div/div/div[2]/div[2]", document, null, 9, null).singleNodeValue; return fun(e) })(), error: [type: MAP, value: {type=object, subtype=error, className=TypeError, description=TypeError: Cannot read properties of null (reading 'textContent')
at fun (<anonymous>:1:46)
at <anonymous>:1:210
at <anonymous>:1:219, objectId=-8260258005070263486.13.89}]

Error: The operation was canceled.

Locally everything works as expected, but from GH Actions not. I use Karate 1.4.1, and everytime i have one of those errors.

If it is possible, how to configure Karate UI to run from GH Actions, i can't find any examples in the web

UPD: One problem with cancelled operation was fixed by increasing timeout parameter in .yml file. Problem with PolyglotException still actual

runs-on: ubuntu-latest
timeout-minutes: 10
0

There are 0 answers