我嘗試使用 selenium 庫登錄 facebook,但出現(xiàn)了一些問題。輸入憑據(jù)并單擊登錄按鈕后,我收到一條錯誤消息:Cookies RequiredCookies are not enabled on your browser. Please enable cookies in your browser preferences to continue.我已經(jīng)在互聯(lián)網(wǎng)上尋找答案,所以我嘗試了driver.manage().getCookies();并且得到了相同的結(jié)果。這是我的代碼: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();
1 回答

天涯盡頭無女友
TA貢獻1831條經(jīng)驗 獲得超9個贊
我知道在問題中我說過我嘗試訪問 www.facebook.com 但在實際項目中我正在訪問個人資料。
當(dāng)你去https://www.facebook.com時它工作得很好但是error occurs when your going to a profile or if you have second authentication activated.
添加回答
舉報
0/150
提交
取消