FirefoxDriver () не принимает экземпляр ProfilesIni в качестве аргумента - PullRequest
0 голосов
/ 29 августа 2018

Я следую примеру на этой странице, чтобы настроить используемый профиль:

http://toolsqa.com/selenium-webdriver/custom-firefox-profile/

Однако в моем коде я получаю сообщение об ошибке «Удалить аргумент, соответствующий драйверу Firefox»:

    ProfilesIni profile = new ProfilesIni();

    FirefoxProfile myprofile = profile.getProfile("testProfile");

    WebDriver driver = new FirefoxDriver(myprofile); // does not like myprofile as an argument here

Спасибо

UPDATE

Мне удалось решить эту проблему, слегка изменив решение try-catch:

    ProfilesIni profile = new ProfilesIni();
    FirefoxProfile myprofile = profile.getProfile("testProfile"); //added this

    FirefoxOptions options = new FirefoxOptions();
    options.setProfile(myprofile);

1 Ответ

0 голосов
/ 29 августа 2018

В соответствии с документами API FirefoxDriver отсутствует FirefoxDriver(ProfilesIni) подпись, а ProfilesIni не имеет базового класса и не реализует интерфейс, который доступен как сигнатура конструктора для FirefoxDriver.

Через подпись FirefoxDriver(FirefoxOptions). И FirefoxDriver имеет метод setProfile(FirefoxProfile profile).

Это должно работать:

ProfilesIni profile = new ProfilesIni();

FirefoxOptions options = new FirefoxOptions();
options.setProfile(profile.getProfile("testProfile"));

WebDriver driver = new FirefoxDriver(options);
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...