[英]How to launch Chrome Extension using Automation (Robot Framework, etc.)
我需要在自动化中启动特定的chrome扩展。 我目前正在使用Selenium和Java。 但是我无法启动Chrome扩展程序。
基本上有两种方法。
1.在运行时安装所需的扩展 - https://dev.to/razgandeanu/testing-chrome-extensions-with-selenium-491b
2.手动安装所需的扩展程序执行现有的浏览器配置文件并使用selenium中的现有配置文件 。 像这样:
package packageName;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class WebdriverSetup {
public static String chromedriverPath = "C:\\Users\\pburgr\\Desktop\\selenium-tests\\GCH_driver\\chromedriver.exe";
// my default profile folder
public static String chromeProfilePath = "C:\\Users\\pburgr\\AppData\\Local\\Google\\Chrome\\User Data";
public static WebDriver driver;
public static WebDriver startChromeWithCustomProfile() {
System.setProperty("webdriver.chrome.driver", chromedriverPath);
ChromeOptions options = new ChromeOptions();
// loading Chrome with my existing profile instead of a temporary profile
options.addArguments("user-data-dir=" + chromeProfilePath);
driver = new ChromeDriver(options);
driver.manage().window().maximize();
return driver;
}
public static void shutdownChrome() {
driver.close();
driver.quit();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.