I'm writing code to test the facebook website login feature. My chrome browser successfully launches and can enter user and password but I'm unable to select the 'Accept All' button when the test first goes on the website for the cookies.
My code goes onto Facebook.com then tries to find the accept all button. But I can get exception
element not interactable: element has zero size
WebDriver driver = new ChromeDriver();
driver.get("http://www.facebook.com");
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.findElement(By.xpath("//*[@id=\"facebook\"]/body")).click();
Below is the output of inspect
<button value="1" class="_42ft _4jy0 _9o-t _4jy3 _4jy1 selected _51sy" data-cookiebanner="accept_button" data-testid="cookie-policy-banner-accept" title="Accept All" type="submit" id="u_0_j_wR">Accept All</button>
//button[.='Accept All']
As well as adding a webdriver wait would solve your issue.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments