Karate UI cross browser examples - karate

Does someone have any examples of how to run cross browser UI tests in karate? I know from Peter's twitter feed that its possible but anyone having some examples?
Thanks

Look at this example: test-01.feature
It is a Scenario Outline and each row changes the value of * configure driver = config, see the Examples at the end:
Examples:
| config |
| { type: 'chrome' } |
| { type: 'chromedriver' } |
| { type: 'geckodriver' } |
Another strategy could be to re-run the test with different values of karate.env or use call and loop over a second feature file.

Related

Karate UI testing open one browser instance for all test cases [duplicate]

I am able to execute WebUI feature file against single browser (Zalenium) using parallel runner and defined driver in karate-config.js. How can we execute WebUI feature file against multiple browsers (Zalenium) using parallel runner or distributed testing?
Use a Scenario Outline and the parallel runner. Karate will run each row of an Examples table in parallel. But you will have to move the driver config into the Feature.
Just add a parallel runner to this sample project and try: https://github.com/intuit/karate/tree/master/examples/ui-test
Scenario Outline: <type>
* def webUrlBase = karate.properties['web.url.base']
* configure driver = { type: '#(type)', showDriverLog: true }
* driver webUrlBase + '/page-01'
* match text('#placeholder') == 'Before'
* click('{}Click Me')
* match text('#placeholder') == 'After'
Examples:
| type |
| chrome |
| geckodriver |
There are other ways you can experiment with, here is another pattern when you have a normal Scenario in main.feature - which you can then call later from a Scenario Outline from a separate "special" feature - which is used only when you want to do this kind of parallel-ization of UI tests.
Scenario Outline: <config>
* configure driver = config
* call read('main.feature')
Examples:
| config! |
| { type: 'chromedriver' } |
| { type: 'geckodriver' } |
| { type: 'safaridriver' } |
EDIT - also see this answer: https://stackoverflow.com/a/62325328/143475
And for other ideas: https://stackoverflow.com/a/61685169/143475
EDIT - it is possible to re-use the same browser instance for all tests and the Karate CI regression test does this, which is worth studying for ideas: https://stackoverflow.com/a/66762430/143475

Call table usage in Karate UI (Kittens example ). Can we use call table feature to iterate in UI and run the scenario one set of data at a time [duplicate]

I am able to execute WebUI feature file against single browser (Zalenium) using parallel runner and defined driver in karate-config.js. How can we execute WebUI feature file against multiple browsers (Zalenium) using parallel runner or distributed testing?
Use a Scenario Outline and the parallel runner. Karate will run each row of an Examples table in parallel. But you will have to move the driver config into the Feature.
Just add a parallel runner to this sample project and try: https://github.com/intuit/karate/tree/master/examples/ui-test
Scenario Outline: <type>
* def webUrlBase = karate.properties['web.url.base']
* configure driver = { type: '#(type)', showDriverLog: true }
* driver webUrlBase + '/page-01'
* match text('#placeholder') == 'Before'
* click('{}Click Me')
* match text('#placeholder') == 'After'
Examples:
| type |
| chrome |
| geckodriver |
There are other ways you can experiment with, here is another pattern when you have a normal Scenario in main.feature - which you can then call later from a Scenario Outline from a separate "special" feature - which is used only when you want to do this kind of parallel-ization of UI tests.
Scenario Outline: <config>
* configure driver = config
* call read('main.feature')
Examples:
| config! |
| { type: 'chromedriver' } |
| { type: 'geckodriver' } |
| { type: 'safaridriver' } |
EDIT - also see this answer: https://stackoverflow.com/a/62325328/143475
And for other ideas: https://stackoverflow.com/a/61685169/143475
EDIT - it is possible to re-use the same browser instance for all tests and the Karate CI regression test does this, which is worth studying for ideas: https://stackoverflow.com/a/66762430/143475

Karate UI: How to run multiple scenarios in parallel in a single feature file [duplicate]

I am able to execute WebUI feature file against single browser (Zalenium) using parallel runner and defined driver in karate-config.js. How can we execute WebUI feature file against multiple browsers (Zalenium) using parallel runner or distributed testing?
Use a Scenario Outline and the parallel runner. Karate will run each row of an Examples table in parallel. But you will have to move the driver config into the Feature.
Just add a parallel runner to this sample project and try: https://github.com/intuit/karate/tree/master/examples/ui-test
Scenario Outline: <type>
* def webUrlBase = karate.properties['web.url.base']
* configure driver = { type: '#(type)', showDriverLog: true }
* driver webUrlBase + '/page-01'
* match text('#placeholder') == 'Before'
* click('{}Click Me')
* match text('#placeholder') == 'After'
Examples:
| type |
| chrome |
| geckodriver |
There are other ways you can experiment with, here is another pattern when you have a normal Scenario in main.feature - which you can then call later from a Scenario Outline from a separate "special" feature - which is used only when you want to do this kind of parallel-ization of UI tests.
Scenario Outline: <config>
* configure driver = config
* call read('main.feature')
Examples:
| config! |
| { type: 'chromedriver' } |
| { type: 'geckodriver' } |
| { type: 'safaridriver' } |
EDIT - also see this answer: https://stackoverflow.com/a/62325328/143475
And for other ideas: https://stackoverflow.com/a/61685169/143475
EDIT - it is possible to re-use the same browser instance for all tests and the Karate CI regression test does this, which is worth studying for ideas: https://stackoverflow.com/a/66762430/143475

TestCafe fails to retrieve elements after appcues configuration is added

I'm using TestCafe for all my web tests and things were working fine until some configuration files were updated in the web project with some app cues to work. Most of the tests fail but not all which makes it really tricky to figure out what is the problem.
Here is the problem:
A function that specifies a selector can only return a DOM node, an array of nodes, NodeList, HTMLCollection, null or undefined. Use ClientFunction to return other values.
Browser: Chrome 78.0.3904 / Mac OS X 10.14.6
47 | return Selector('div').withExactText('Project').nextSibling().find('div')
48 | .find(`${this.headLocator}.${Name}`);
49 | }
50 |
51 | async BreakDownCount(Name) {
> 52 | return helper.getIntFromString(await this.BreakdownLocator(Name).textContent);
Here is the code:
BreakdownLocator(Name) {
return Selector('div').withExactText('Project').nextSibling().find('div')
.find(`${this.headerLocator}.${Name}`);
}
async BreakDownCount(Name) {
return helper.getIntFromString(await this.BreakdownLocator(Name).textContent);
}
I have a feeling that it fails where I use async functions or promise as there are other tests that didn't fail but they don't have promise. I looked around and found this discussion but this didn't help. Any suggestions?

How to execute tests (multiple feature files) across environments in parallel in Karate DSL

How to execute tests(feature files) across multiple environments in parallel using Karate DSL
I have two feature files which I need to execute in parallel across the different environments.
Use a second feature file, and call the feature you want in 2 scenarios, but passing different arguments.
You can even use a Scenario Outline, for an example see this:
Scenario Outline:
* call read('some.feature') <config>
Examples:
| config |
| { type: 'chrome' } |
| { type: 'chromedriver' } |
| { type: 'geckodriver' } |