1)我的Firefox安装在以下路径C:\Program Files\Mozilla Firefox\firefox.exe
上2)我使用的是Windows 7 64位版本。
3)我使用的是Firefox 46.0版本。
4)我使用的是selenium-java-2.53.0版本。
5)Firefox配置文件位于C:\Users\xxxxxx\automation
我创建了单独的配置文件并尝试在代码中使用相同但仍然只是在匿名临时配置文件中创建Web驱动程序。请帮我解决这个问题。
我做过这些方法。
第一种方法
ProfilesIni profile = new ProfilesIni(); FirefoxProfile myprofile = profile.getProfile("automation");
DesiredCapabilities capability = DesiredCapabilities.firefox(); capability.setCapability(FirefoxDriver.PROFILE, myprofile);
driver = new FirefoxDriver(capability);
第二种方法
ProfilesIni profile = new ProfilesIni();
FirefoxProfile myprofile = profile.getProfile("automation");
driver = new FirefoxDriver(myprofile);
第三种方法
FirefoxProfile myprofile =profile.getProfile("C:\\Users\\xxxx\\NewProfile");driver = new FirefoxDriver(myprofile);
第四种方法
FirefoxProfile myprofile=new FirefoxProfile(new File("C:\\Users\\xxxxx\\NewProfile"));driver = new FirefoxDriver(myprofile);
注意:当我执行以下命令' C:\ Program Files \ Mozilla Firefox \ firefox.exe" -p'它的显示2个配置文件首先是default
,另一个是我为自动化创建的automation
名称,并且可以手动启动而没有任何问题。
但是当我执行自动化操作时,关于:支持"在firefox地址栏中,查看了仅显示匿名临时配置文件的配置文件夹。