Hi I have a selenium cucumber project with some tests. The tests worked and the chromeDriver had launch when I run the -mvn clean compile test in my IDE. I created this .gitlab-ci.yml in my projec...
oh, you mentioned checking screenshot before, but I did not notice at all. (sorry)
yes, I configured the taking screenshot in the step that the problem happens.
And as you know I have the same problem in headLess mode even the IDE mode.
so, I run the test again in IDE in headLess mode and face that error and checked the screenshot and I noticed that the browser window zooms in on the screen and the link that I need to click on that is disappear!!!
Please Look:
the page that I expect:
and I want to click on "Sign In". but the page that taken screenshot:
which the sign-in link is gone...
so, I added this maximization option that you mentioned before:
options.addArguments("start-maximized");
And it made no difference.
so, I replaced it with this:
driver.manage().window().maximize();
And the error is gone. but now, I face this error again:
Unable to load browser: null
Failure in before hook:MasterHooks.setup()
Message: java.lang.AssertionError
at utils.DriverFactory.getDriver(DriverFactory.java:38)
at stepDefinitions.MasterHooks.setup(MasterHooks.java:15)
this is the DriverFactorry file:
package utils;
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.support.PageFactory;
import pageObjects.Login_page;
import java.io.FileInputStream;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
public class DriverFactory {
public static WebDriver driver;
public static Login_page loginPage;
public WebDriver getDriver() {
try {
// Read Config
Properties p = new Properties();
FileInputStream fi = new FileInputStream(System.getProperty("user.dir") + "/src/main/java/properties/config.properties");
p.load(fi);
String browserName = p.getProperty("browser");
if ("chrome".equals(browserName)) {
if (null == driver) {
WebDriverManager.chromedriver().setup();
ChromeOptions options = new ChromeOptions();
options.setHeadless(true);
driver.manage().window().maximize();
driver = new ChromeDriver(options);
}
}
} catch (Exception e) {
System.out.println("Unable to load browser: " + e.getMessage());
} finally {
assert driver != null;
driver.manage().timeouts().pageLoadTimeout(60, TimeUnit.SECONDS);
loginPage = PageFactory.initElements(driver, Login_page.class);
}
return driver;
}
}
> I noticed that the browser window zooms in on the screen and the link that I need to click on that is disappear!!! Please Look:
It looks like this is a responsive issue. Chrome headless seems to have a lower definition than regular, so it apply css breakpoints to github.
Testing github is part of your test-suite? Or is it a "Hello world" test to setting things up?
To fix this, in the chrome options, try adding something like this: `options.addArguments("window-size=1920,1080")`. I'll let you look for some documentation if you need to.
Forget about driver.manage().window().maximize(): in headless mode, you won't have any window at all, so it won't ever work.
It seems like you managed to fix the issue. I have the same problem you did face. I do however, use gitpod for my project, with maven, gitlab and monocle.
Could you post a link of the final project for me to use as guidance?