Karate Framework 无法覆盖 SSL。

huangapple go评论96阅读模式
英文:

Karate Framework cannot override ssl

问题

我正在尝试在Docker中使用独立的Karate .jar文件。我正在将其连接到我的Selenium Grid Docker容器。我需要在Jenkins上运行这个,所以我希望利用现有的Selenium Grid基础设施。

我有一个简单的测试,用于导航到Google并搜索一些内容。我收到了'Privacy Error'。我尝试使用'acceptInsecureCerts',我尝试了'configure ssl = true',以及我尝试了'configure ssl = { trustAll: true }'。似乎什么都不起作用。

我想知道我做错了什么。我是不是没有正确使用它们?我需要做其他什么吗?

我有一个特性,调用另一个特性,再调用另一个特性。这是为了测试Chrome,Edge和Firefox。

上面的特性调用了这个特性。我正在尝试设置Chrome的能力,如此处所述:链接

上面的特性调用了这个特性

我正在使用以下命令运行Docker容器。这里我使用了-s标志,如此处所述:链接

docker run -it --rm -v ${PWD}/src:/src -w /src --name "karate-jre" --network host karate-jre java -jar /karate.jar -s .
英文:

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 .

答案1

得分: 0

configure ssl 语法仅适用于用于 API 测试的 HTTP 客户端。

对于 WebDriver,您需要调整的是驱动程序配置中的 httpConfig 键。请参考文档的这部分内容:https://github.com/karatelabs/karate/tree/master/karate-core#configure-driver(并搜索 httpConfig)。

而在 httpConfig JSON 中,您可以嵌套任何在此处描述的内容:https://github.com/karatelabs/karate#configure。例如:

  • def httpConfig = { ssl: true }
  • configure driver = { type: 'chromedriver', httpConfig: '#(httpConfig)' webDriverSession: '#(session)', start: false, webDriverUrl: 'http://localhost:4444/wd/hub' }
英文:

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' }

huangapple
  • 本文由 发表于 2023年8月11日 04:34:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/76879154.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定