Hi I am trying to automate
Please let me know if i am missing anything here.
CodePudding user response:
To click() on the element with text as Log In / SignUp you can use either of the following Locator Strategies:
xpath:driver.findElement(By.xpath("//div[starts-with(@id, 'defaultAvatar')]//following::span[text()='Log In / SignUp']")).click();
However, as the element is a dynamic element, so to click() on the element you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following Locator Strategies:
xpath:new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//div[starts-with(@id, 'defaultAvatar')]//following::span[text()='Log In / SignUp']"))).click();
CodePudding user response:
Actually your code is clicking the login button before the page is loaded properly. please add visibility condition.
wait.until(ExpectedConditions.visibilityOfElementLocated(by));
