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

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

嘗試通過 FirefoxProfile 打開網站時出現

嘗試通過 FirefoxProfile 打開網站時出現

蠱毒傳說 2021-06-08 17:01:55
我正在運行下面的代碼,打開一個 URL。但是,我收到錯誤消息為“NoSuchSessionException”。請建議。是不是因為我使用的以下版本。Selenium--> 3.12.0,Firefox Setup 50.0 和 geckodriver-v0.21.0-win64import java.util.concurrent.TimeUnit;   import org.openqa.selenium.WebDriver;   import org.openqa.selenium.firefox.FirefoxDriver;   import org.openqa.selenium.firefox.FirefoxOptions;   import org.openqa.selenium.firefox.FirefoxProfile;   import org.openqa.selenium.firefox.internal.ProfilesIni;public class Gmail {public static void main(String[] args){System.setProperty("webdriver.gecko.driver", "D:\\Drivers\\geckodriver.exe");FirefoxOptions options = new FirefoxOptions();  ProfilesIni allProf = new ProfilesIni();// all profilesFirefoxProfile prof = allProf.getProfile("Abhi_Selenium");options.setProfile(prof);//FirefoxDriver driver = new FirefoxDriver(options);WebDriver driver = new FirefoxDriver(options);driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);driver.get("http://gmail.com");}}
查看完整描述

3 回答

?
慕尼黑5688855

TA貢獻1848條經驗 獲得超2個贊

您可以使用FireFoxProfile類和FirefoxOptions類來設置配置文件。


FirefoxOptions options = new FirefoxOptions(); 

FirefoxProfile firefoxProfile  = new FirefoxProfile(pathToProfile);

options.setProfile(firefoxProfile);


查看完整回答
反對 回復 2021-06-17
?
LEATH

TA貢獻1936條經驗 獲得超7個贊

乍一看,firefox.exe 的路徑丟失了。有我的設置:


public class foo{

    private static WebDriver driver;


@BeforeClass

    public static void setUpClass() {

        FirefoxOptions options = new FirefoxOptions();

        ProfilesIni allProfiles = new ProfilesIni();         

        FirefoxProfile selenium_profile = allProfiles.getProfile("selenium_profile");

        options.setProfile(selenium_profile);

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

        System.setProperty("webdriver.gecko.driver", "C:\\Users\\pburgr\\Desktop\\geckodriver-v0.20.0-win64\\geckodriver.exe");

        driver = new FirefoxDriver(options);

        driver.manage().window().maximize();}


// @Before, @After, @AfterClass and @Test


}


查看完整回答
反對 回復 2021-06-17
  • 3 回答
  • 0 關注
  • 157 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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