簡體   English   中英

如何在WebDriver中訪問添加的插件

[英]How to access added plugins in webdriver

我在chrome中添加了一個插件,但是如何通過webdriver訪問它

File addonpath = new File("path of .crx file");
ChromeOptions chrome = new ChromeOptions();
chrome.addExtensions(addonpath);
WebDriver driver = new ChromeDriver(chrome );

嗨,請像下面這樣

public class ChromeProfileWithAddOn {

public static void main(String[] args) {
    // TODO Auto-generated method stub

    DesiredCapabilities capabilities = DesiredCapabilities.chrome();
    // Add ChromeDriver-specific capabilities through ChromeOptions.
    // i have added this add on on chrome  = https://chrome.google.com/webstore/detail/pdf-converter/dmgnkfgleaamgbhhojkfijjmjmngokkb 
    ChromeOptions options = new ChromeOptions();
    options.addArguments("start-maximized");  
 ########paste the location of .crx file you get in step 6 here########
        options.addExtensions(new File("C:\\Users\\###\\Desktop\\hgmloofddffdnphfgcellkdfbfbjeloo.crx"));
    capabilities.setCapability(ChromeOptions.CAPABILITY, options);

    System.getProperty("webdriver.chrome.driver","D:\\eclipseProject\\###\\src\\com\\###\\chromedriver_win32 (1)\\chromedriver.exe");
    ChromeDriver driver = new ChromeDriver(capabilities);
    // call chrome driver
    driver.navigate().to("chrome-extension://ldlmdngominhfffemgnfpoifladkpple/RestClient.html");
How to get above url : 
1.open the mainfest.json file there you will find  "local_path":"RestClient.html"
2. make sure your extension is installed in chrome and then 
3. go to chrome://extensions/ (follow steps-3 and 4 below)
4. you will get an ID value as shown in the image just below step 4 copy that
5. now u can make your url as "chrome-extension://ID/local_path"
6. now open it in chrome browser
} }

代碼將如上所述,但我們必須遵循一些基本步驟:

注意 :我在說以下** CHROME ** URL的高級REST客戶端示例: https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo : https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo

第1步 :

 `Please download or if in-case already present go to the extension's manifest.json file` 

如果您想將加載項下載到本地驅動器上,請遵循以下步驟:

a。>下載此擴展程序https://chrome.google.com/webstore/detail/chrome-extension-source-v/jifpbeccnghkjeaalbbjmodiffmgedin

b。>安裝它(在Chrome瀏覽器的右上角,將顯示一個CRX按鈕)

c。>現在在Chrome網上應用店中搜索Advanced REST客戶端 ,或者簡單地將鏈接復制並粘貼到瀏覽器中

https://chrome.google.com/webstore/detail/advanced-rest-client/hgmloofddffdnphfgcellkdfbfbjeloo

d。>單擊CRX圖像/按鈕,您將獲得兩個選項 在此處輸入圖片說明

選擇以zip格式下載(保存在您的首選位置)。

e。>解壓縮

f。>在解壓縮的文件夾中,您會找到manifest.json文件

第2步 :

Copy the location of mainfest.json file 

第3步:轉到Chrome瀏覽器,然后在網址中輸入

 chrome://extensions/  

此處將顯示所有已安裝的附件/擴展名

第四步 :

please check the Developer option

Pack Extension的選項現在將可見

在此處輸入圖片說明

步驟5:單擊Pack Extension,然后在Extension根目錄下:(第一個選項)粘貼manifest.json文件的位置。 在此處輸入圖片說明

步驟6:如果您已按照上述步驟進行操作,您將得到此信息 在此處輸入圖片說明

希望這可以解決您的查詢。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM