Closed subiron closed 4 years ago
The ChromeDriver 2.29 is not supporting version 59. We should wait for new release
@Shaihuludus ChromeDriver 2.32 is providing support for headless. Are you providing any support for headless?
@mkrzyzanowski @subiron @mmajchrzak
please can you provide us the headless support for ChromeDriver 2.32 as @venkateswaris request. Please this is a blocker to us in using bobcat as a framework for our automation.
Many Thanks Reed QA
Hi, @venkateswaris and @reedsexpo!
Since we are not providing any version of ChromeDriver bundled with Bobcat, you are free to use the latest version that supports the headless mode in Chrome. To make it work though, a bit of additional code is required. You must add it to your own codebase for now,
We are going to use CapabilitiesModifier
to add the necessary Chrome options and introduce two new properties to control the headless mode:
webdriver.properties
(or any other .properties
file):webdriver.chrome.headless=true
webdriver.chrome.headless.disableGpu=false
CapabilitiesModifier
:public class ChromeOptionsModifier implements CapabilitiesModifier {
@Inject
@Named("webdriver.chrome.headless")
private boolean enabled;
@Inject
@Named("webdriver.chrome.headless.disableGpu")
private boolean disableGpu;
@Override
public boolean shouldModify() {
return enabled;
}
@Override
public Capabilities modify(Capabilities capabilities) {
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("headless");
if(disableGpu) {
chromeOptions.addArguments("disable-gpu");
}
Capabilities chromeCapabilites = DesiredCapabilities.chrome();
((DesiredCapabilities)capabilities).setCapability(ChromeOptions.CAPABILITY, chromeOptions);
return chromeCapabilites.merge(capabilities);
}
}
GuiceModule.java
public class GuiceModule extends AbstractModule {
@Override
protected void configure() {
install(new CoreModule());
// other modules or bindings
Multibinder<CapabilitiesModifier> capabilitiesModifierMultibinder =
Multibinder.newSetBinder(binder(), CapabilitiesModifier.class);
capabilitiesModifierMultibinder.addBinding().to(ChromeOptionsModifier.class);
}
}
Now you can toggle the headless mode using the webdriver.chrome.headless
property :).
Hello @mkrzyzanowski,
I have generated a new 'bobcat-aem-bdd' using gradlew, following the instructions in https://github.com/Cognifide/bobcat-gradle-template
I am able to start the tests on chrome browser as a first step, and this is working.
Secondly, when I tried to execute the tests on headless chrome, by modifying all config.yaml and chrome.yaml properties file, this didn't work. After some research, I found this link and did exactly as mentioned above. And, the tests are still running on chrome browser instead of headless browser.
I am fairly new to bobcat and test automation, not sure what am I doing wrong please suggest,
Steps to reproduce,
default: properties: proxy.enabled: false proxy.ip: 127.0.0.1 proxy.port: 9000 bobcat.report.path: ./target/report bobcat.report.reporters: html,json,simple,stdout webdriver.defaultTimeout: 10 page.title.timeout: 30 thread.count: 3 webdriver.chrome.headless: true webdriver.chrome.headless.disableGpu: false contexts: [chrome,locator,dev]
import org.openqa.selenium.Capabilities; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.remote.DesiredCapabilities; import com.cognifide.qa.bb.provider.selenium.webdriver.modifiers.capabilities.CapabilitiesModifier; import com.google.inject.Inject; import com.google.inject.name.Named;
import com.cognifide.qa.bb.provider.selenium.webdriver.modifiers.capabilities.CapabilitiesModifier; import com.google.inject.multibindings.Multibinder;
Hello @mkrzyzanowski,
I have updated the documentation for 'bobcat-gradle-template' on the issues that I encountered, please approve if it is appropriate. https://github.com/Cognifide/bobcat-gradle-template/pull/11
Note: Couldn't add you as reviewer.
Hi @mkrzyzanowski, Following the instructions above I get the errors below when I try to run on Chrome in headless mode. Any suggestions on how to fix this?
` 1) No implementation for java.lang.Boolean annotated with @com.google.inject.name.Named(value=webdriver.chrome.headless.disableGpu) was bound. while locating java.lang.Boolean annotated with @com.google.inject.name.Named(value=webdriver.chrome.headless.disableGpu) for field at bobcat.ChromeOptionsModifier.disableGpu(ChromeOptionsModifier.java:10) at bobcat.GuiceModule.configure(GuiceModule.java:35)
2) No implementation for java.lang.Boolean annotated with @com.google.inject.name.Named(value=webdriver.chrome.headless) was bound. while locating java.lang.Boolean annotated with @com.google.inject.name.Named(value=webdriver.chrome.headless) for field at bobcat.ChromeOptionsModifier.enabled(ChromeOptionsModifier.java:10) at bobcat.GuiceModule.configure(GuiceModule.java:35) `
Hi @vagwada,
seems like you don't have the properties mentioned in the stack trace in your config. If you are using the latest Bobcat version, 1.6.0
, then you should put these in the config.yaml
file :).
Awesome, I'll give that a try, thanks! On Sun, Nov 4, 2018 at 12:59 PM Michał Krzyżanowski < notifications@github.com> wrote:
Hi @vagwada https://github.com/vagwada,
seems like you don't have the properties mentioned in the stack trace in your config. If you are using the latest Bobcat version, 1.6.0, then you should put these in the config.yaml file :).
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Cognifide/bobcat/issues/188#issuecomment-435705385, or mute the thread https://github.com/notifications/unsubscribe-auth/AOrJvGRzIDPQ3pI1Ipkzy7UKmPomVXqPks5ur1UxgaJpZM4Na5N4 .
@mkrzyzanowski
can we use the same approach for below option?
ChromeOptions options = new ChromeOptions(); options.addArguments("--disable-site-isolation-trials");
Ref: https://bugs.chromium.org/p/chromedriver/issues/detail?id=2660
Done in #314
@mkrzyzanowski When it will be released?
Released in 2.2.0
Starting from version 59 chrome supports headless mode (on linux and MacOs) this may improve the performance of tests.
Please check if all existing features still works in this mode and measure performance differences.
Also please provide docs how to execute tests in headless mode for chrome.
see https://developers.google.com/web/updates/2017/04/headless-chrome