Reputation: 421
Both the options --window-size or --incognito are not working with chromedriver. However the same options works perfectly with type chrome. I tried option --start-maximized but this also not working. I have maintained the driver configutation in karate-config.js.
function fn() {
let env = karate.env;
karate.configure('ssl', true);
karate.log('karate.env system property was:', env);
if (!env) {
//Java function to read browser value from properties
env = Java.type('examples.users.utilities.ConfigReader').read("app.target.browser").trim();
}
const config = {
env: env,
};
switch (env) {
case "chrome":
//Java function to get screen resolution/dimension
//Java function to get screen chrome driver file path
karate.configure('driver', {
type: 'chromedriver',
executable: Java.type('examples.users.utilities.Miscellaneous').getDriverFilePath() + "chromedriver.exe",
addOptions: ["--window-size=\"" + Java.type('examples.users.utilities.Miscellaneous').getWindowResolution() + "\"", "--disable-extensions"]
});
break;
case "firefox":
karate.configure('driver', {
type: 'firefox',
addOptions: ["--incognito", "--window-size=\"" + Java.type('examples.users.utilities.Miscellaneous').getWindowResolution() + "\"", "--disable-extensions"]
});
break;
default:
karate.log('Given browser is not present');
}
return config;
}
Here the Feature file.
Feature: Launch browser example 1
Scenario: Open google and enter text to search
Given driver 'https://www.google.com'
When input("input[type=text]", 'karate')
And submit()
Below are folder structure and complete source can be found here.
Upvotes: 1
Views: 608
Reputation: 58128
As far as I know, those options only work for chrome
. This is an area where we welcome contributions and research.
Also see: https://stackoverflow.com/a/62700642/143475
Upvotes: 1