亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何處理日志信息在 selenium 項目中使用 `new FirefoxOptions()`

如何處理日志信息在 selenium 項目中使用 `new FirefoxOptions()`

神不在的星期二 2023-03-23 16:39:16
我剛開始一個 selenium 項目,但事情并不順利,所以在搜索了一下之后我找到了這個解決方案。它有效,但我無法理解這些紅色語句要我做什么,或者如何擺脫它們。import org.openqa.selenium.WebDriver;import org.openqa.selenium.firefox.FirefoxBinary;import org.openqa.selenium.firefox.FirefoxDriver;import org.openqa.selenium.firefox.FirefoxOptions;import org.openqa.selenium.remote.DesiredCapabilities;import java.io.*;public class SelTest1{    public  static void main(String [] args)    {        System.setProperty("webdriver.gecko.driver","X:\\Gecko\\geckodriver-v0.24.0-win64\\geckodriver.exe");        File pathBinary = new File("X:\\FireFoxx\\firefox.exe");        FirefoxBinary firefoxBinary = new FirefoxBinary(pathBinary);        DesiredCapabilities desired = DesiredCapabilities.firefox();        FirefoxOptions options = new FirefoxOptions();        desired.setCapability(FirefoxOptions.FIREFOX_OPTIONS, options.setBinary(firefoxBinary));        WebDriver obj = new FirefoxDriver(options);        obj.get("http://www.google.com/");    }}我得到了我想要的結果,但我不明白警告{紅色聲明}我把那些紅線{警告也放在這里是為了方便}Jul 12, 2019 7:07:28 PM org.openqa.selenium.remote.DesiredCapabilities firefoxINFO: Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`1562938650997   mozrunner::runner   INFO    Running command: "X:\\FireFoxx\\firefox.exe" "-marionette" "-foreground" "-no-remote" "-profile" "C:\\Users\\adars\\AppData\\Local\\Temp\\rust_mozprofile.uTUmeENutxin"1562938652637   [email protected] WARN    Loading extension '[email protected]': Reading manifest: Invalid extension permission: mozillaAddons1562938652638   [email protected] WARN    Loading extension '[email protected]': Reading manifest: Invalid extension permission: resource://pdf.js/1562938652638   [email protected] WARN    Loading extension '[email protected]': Reading manifest: Invalid extension permission: about:reader*
查看完整描述

1 回答

?
蝴蝶不菲

TA貢獻1810條經驗 獲得超4個贊

此信息日志消息:


INFO: Using `new FirefoxOptions()` is preferred to `DesiredCapabilities.firefox()`

是包含在以下內容中的更改的結果:


硒 v3.0.0-beta4


Added ability to use FirefoxOptions when starting firefox.

硒 v3.5.0


* Start making *Option classes instances of Capabilities. This allows

  the user to do:


  `WebDriver driver = new RemoteWebDriver(new InternetExplorerOptions());`

如果您的用例是明確提及的絕對位置,FirefoxBinary您可以使用以下解決方案:


使用FirefoxOptions:


import org.openqa.selenium.WebDriver;

import org.openqa.selenium.firefox.FirefoxDriver;

import org.openqa.selenium.firefox.FirefoxOptions;


public class A_Firefox_binary 

{

    public static void main(String[] args) 

    {

        System.setProperty("webdriver.gecko.driver", "C:/Utility/BrowserDrivers/geckodriver.exe");

        FirefoxOptions options = new FirefoxOptions();

        options.setBinary("C:\\Program Files\\Mozilla Firefox\\firefox.exe");

        WebDriver driver =  new FirefoxDriver(options);

        driver.get("https://stackoverflow.com");

        System.out.println("Page Title is : "+driver.getTitle());

        driver.quit();

    }

}

控制臺輸出:


Page Title is : Stack Overflow - Where Developers Learn, Share, & Build Careers


查看完整回答
反對 回復 2023-03-23
  • 1 回答
  • 0 關注
  • 136 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號