Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

URL is not opening in headless chrome using Selenium java and windows os

I am facing below issue while running scripts on chrome headless using Selenium java and in Windows OS. URL is not opening i am getting null as a title of page for my application URL..chrome driver version 2.33 ,chrome browser 62..I am using below code

System.setProperty("webdriver.chrome.driver", chromedriver.exe);
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("window-sized1200,600");
ChromeDriver driver = new ChromeDriver(chromeOptions);
driver.get("app url");
System.out.println(driver.getTitle)

Is it because by app URL is not supported headless mode ..not getting any exception..

like image 588
Amruta Avatar asked Dec 05 '25 18:12

Amruta


1 Answers

There is a typo in your window size argument and you call addArguments but you only add one argument per call, try this

ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.addArguments("headless", "window-size=1200,600");
ChromeDriver driver = new ChromeDriver(chromeOptions);
driver.get("your.app.url");
System.out.println(driver.getTitle)
like image 113
Marcel Avatar answered Dec 07 '25 07:12

Marcel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!