package newpackage;
import java.util.List;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.interactions.Actions;
public class OpenAmazon {
public static void main(String[] args) {
WebDriver driver;
System.setProperty("webdriver.chrome.driver", "C:\\Program Files\\chromedriver_win32\\chromedriver.exe");
driver=new ChromeDriver();
driver.get("http://www.amazon.in");
List<WebElement> yourOrders= driver.findElements(By.cssSelector("span[class='nav-line-2']"));
//third element is the your orders
WebElement yourOrder=yourOrders.get(2);
//mouse hover on it to get the sign button
Actions act=new Actions(driver);
act.moveToElement(yourOrder).build();
//click on SignIn button
List<WebElement> signIn= driver.findElements(By.cssSelector("span[class='nav-action-inner']"));
signIn.get(0).click();
}
}
i am using above code to Sign In in Amazon.i am getting Element NotVisibleException for SignIn Button which appears after hover on yourOrders.how to resolve this
While trying to
Sign In
in Amazon you were gettingElementNotVisibleException
forSignIn
Button as theLocator Strategy
you had adapted wasn't uniquely identifying theSign In
button.To
click()
on Sign In button inhttp://www.amazon.in
you can use the following line of code :