Город МОСКОВСКИЙ
00:07:20

Execute Selenium Scripts in Headless Chrome - Windows

Аватар
Легенды кода
Просмотры:
42
Дата загрузки:
01.12.2023 20:56
Длительность:
00:07:20
Категория:
Технологии и интернет

Описание

Please use the following link to install the Katalon Studio:

https://katalon.com/sign-up?getr=krishnaRef Check Tubebuddy Features Here:
https://www.tubebuddy.com/krishnasakinala A headless browser is a web browser without a graphical user interface.
This program will behave just like a browser but will not show any GUI.
Some of the examples of Headless Drivers include htmlunitdriver, phontomjs, nightmare,
slimerjs, triflejs etc... Need to use Chrome options to achieve the headless in chrome
for theat we need to add two arguments called "headless" and "window-size".

import org.openqa.selenium.By;
import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class HeadlessTestWithChrome {

public static void main(String[] args) {
System.setProperty("webdriver.chrome.driver", "Path to chromedriver.exe");

ChromeOptions options = new ChromeOptions();
options.addArguments("window-size=1400,800");
options.addArguments("headless");

WebDriver driver = new ChromeDriver(options);
driver.get("http://automationtesting.in");
System.out.println("Site Title is: "+ driver.getTitle());
driver.findElement(By.cssSelector("#s")).sendKeys("testng");
driver.findElement(By.cssSelector("#s")).sendKeys(Keys.ENTER);
System.out.println("Site Title is: "+ driver.getTitle());
driver.quit();
}
}

Рекомендуемые видео