I am trying to use the stand alone Karate .jar file in docker. I am connecting that to my Selenium Grid docker containers. I need to run this on Jenkins so I wanted to utilize the existing infrastructure of selenium grid.
I have a simple test to navigate to google and search for something. I am getting 'Privacy Error'. I tried to use 'acceptInsecureCerts' and I have tried 'configure ssl = true' and I have tried 'configure ssl = { trustAll: true }'. Nothing seems to work.
I would like to know what I am doing wrong. Am I not using these correctly? Do I need to do something else instead?
I have this feature that calls another feature which calls another feature. This is so I can test Chrome, Edge and Firefox.
Feature: Example UI Test Suite for testing all browsers
Background:
# * configure ssl = true
* configure ssl = { trustAll: true }
Scenario:
* karate.call('ExampleUITestChromeDriver.feature')
# * karate.call('ExampleUITestGeckoDriver.feature')
# * karate.call('ExampleUITestMSEdgeDriver.feature')
The above feature calls this feature. I am trying to set the capabilities of chrome as mentioned here
Feature: Example UI Test
Background:
This is just a simple example of UI testing.
For more info: https://github.com/karatelabs/karate/tree/develop/karate-core#webdriverurl
* configure driver = { type: 'chromedriver', start: false, webDriverUrl: 'http://localhost:4444/wd/hub' }
# * def session = { capabilities: { acceptInsecureCerts: true, alwaysMatch: { browserName: 'chrome', 'goog:chromeOptions': { args: [ '--headless', 'window-size=1280,720' ] } } } }
# * def session = { capabilities: { acceptInsecureCerts: true } }
# * configure driver = { type: 'chromedriver', webDriverSession: '#(session)', start: false, webDriverUrl: 'http://localhost:4444/wd/hub' }
@ignore
Scenario: Sample UI Automation Test
* karate.call('ExampleUITestCommon.feature')
The feature above calls this feature
Feature: Example UI Test Common Tests to be used with each driver instance
@ignore
Scenario: Sample UI Automation Test Google
Given def searchBarXpath = "//textarea[@type='search']"
Given def googleSearchButtonXpath = "///input[@role='button' and @value='Google Search']"
Given def googleSearchResultHeaderXpath = "//h3[text()='Karate UI']"
Given driver 'https://google.com'
And match driver.title == 'Google'
And waitFor(searchBarXpath)
And input(searchBarXpath, 'karate ui automation')
And click(googleSearchButtonXpath)
Then waitFor(googleSearchResultHeaderXpath)
I am using this to run the docker container. Here I am using the -s flag which is mentioned here
docker run -it --rm -v ${PWD}/src:/src -w /src --name "karate-jre" --network host karate-jre java -jar /karate.jar -s .
The configure ssl
syntax applies only to the HTTP client used for API tests.
For WebDriver, what you need to adjust is the httpConfig
key in the driver config. Refer to this part of the documentation: https://github.com/karatelabs/karate/tree/master/karate-core#configure-driver (and search for httpConfig
).
And within the httpConfig
JSON you can nest anything described here. For example:
* def httpConfig = { ssl: true }
* configure driver = { type: 'chromedriver', httpConfig: '#(httpConfig)' webDriverSession: '#(session)', start: false, webDriverUrl: 'http://localhost:4444/wd/hub' }