-1
WebElement element = driver.findElement(By.className("nav-action-button"));  
         Actions actions = new Actions(driver);  
         try {  
             JavascriptExecutor js = (JavascriptExecutor)driver;
          js.executeScript("arguments[0].scrollIntoView(true);", element);  
           actions.moveToElement(element).perform();  
           actions.click(element).perform();  
         } catch (Exception e) {  
          // throw new TestException(String.format("The following element is not clickable: [%s]", element.toString()));  
         }  

I have also tried

WebElement element = driver.findElement(By.id("nav-your-amazon"));  
         Actions actions = new Actions(driver);  
         try {  
             JavascriptExecutor js = (JavascriptExecutor)driver;
          js.executeScript("arguments[0].scrollIntoView(true);", element);  
           actions.moveToElement(element).perform();  
           actions.click(element).perform();  
         } catch (Exception e) {  
          // throw new TestException(String.format("The following element is not clickable: [%s]", element.toString()));  
         }  
  • What is the error? – FDM Apr 17 '17 at 7:22
  • Please edit your post to add the error you are receiving – Kate Paulk Apr 17 '17 at 11:26
4

Just try with different locator type-

WebElement element = driver.findElement(By.xpath("//a[@id='nav-link-yourAccount']/span[1]")); 

OR:

driver.findElement(By.xpath("//span[contains(.,'Hello. Sign in')]"));

OR:

driver.findElement(By.xpath("//span[contains(@class,'nav-line-1')]"));

Followed by adding the same code of Action class.

enter image description here

| improve this answer | |
  • The different suggested locators still do not work, there is no error message but the button is not clicked. I get below error though2017-04-17 07:59:39.044 plugin-container[1917:156853] *** CFMessagePort: bootstrap_register(): failed 1100 (0x44c) 'Permission denied', port = 0x933b, name = 'com.apple.tsm.portname' See /usr/include/servers/bootstrap_defs.h for the error codes. – newtoSelenium Apr 17 '17 at 15:20
  • You can try without using Action class. Use direct element.click() method. – Bharat Mane Apr 18 '17 at 4:45

Not the answer you're looking for? Browse other questions tagged or ask your own question.