Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Java中的selenium登录facebook_Java_Selenium_Selenium Chromedriver - Fatal编程技术网

使用Java中的selenium登录facebook

使用Java中的selenium登录facebook,java,selenium,selenium-chromedriver,Java,Selenium,Selenium Chromedriver,我尝试使用selenium库登录facebook,但出现了一些问题。在输入凭证并单击登录按钮后,我得到一个错误,显示: Cookies Required Cookies are not enabled on your browser. Please enable cookies in your browser preferences to continue. 我在互联网上寻找答案,所以我尝试了driver.manage().getCookies()和我得到相同的结果 这是我的密码: Syste

我尝试使用selenium库登录facebook,但出现了一些问题。在输入凭证并单击登录按钮后,我得到一个错误,显示:

Cookies Required
Cookies are not enabled on your browser. Please enable cookies in your browser preferences to continue.
我在互联网上寻找答案,所以我尝试了
driver.manage().getCookies()和我得到相同的结果

这是我的密码:

System.setProperty("webdriver.chrome.driver", DRIVERLOCATION);
WebDriver driver = new ChromeDriver();
driver.manage().getCookies();


driver.get("https://www.facebook.com");

driver.findElement(By.id("email")).sendKeys(USERNAME);
driver.findElement(By.id("pass")).sendKeys(PASSWORD);
driver.findElement(By.xpath("//input[starts-with(@id, 'u_0_')][@value='Log In']")).click();

我知道在问题中我说我试图访问www.facebook.com,但在实际项目中,我获得了一个个人资料


当您转到时,它可以正常工作,但是当您转到个人资料时,或者如果您激活了第二次身份验证,则会出现
错误。

我知道在问题中我说过我试图访问www.facebook.com,但在实际项目中,我访问的是个人资料


当您转到时,它可以正常工作,但是当您转到配置文件时,或者如果您激活了第二次身份验证,则会出现
错误。

很有趣。你在html正文中看到这条消息了吗?请看…在发出登录请求后,它会将我重定向到另一个页面,上面写着that@GhostCat我尝试过firefox,我得到了同样的结果,并且说cookies是可以启用的。也许你应该起诉facebook。也许他们有办法避免这种“自动化”登录他们的网站。有趣。你在html正文中看到这条消息了吗?请看…在发出登录请求后,它会将我重定向到另一个页面,上面写着that@GhostCat我尝试过firefox,我得到了同样的结果,并且说cookies是可以启用的。也许你应该起诉facebook。也许他们有办法避免这种“自动化”登录他们的网站。