0

enter image description here

I am trying to login to Zoho using automation test in java (selenium) below is the code

WebDriver driver = new ChromeDriver();
/* Access the URL to write auto login test */ 
driver.get("https://www.zoho.com/");
driver.findElement(By.linkText("Sign in")).click();
driver.findElement(By.id("login_id")).sendKeys("email");
driver.findElement(By.xpath("//span[normalize-space()='Next']")).click();
driver.findElement(By.xpath("//input[@id='password']")).sendKeys("password");
driver.findElement(By.id("nextbtn")).click();
  1. above code successfully passes the test for Sign in and accepts the email id.
  2. Then the page gets redirected to another page and here password needs to be given.
  3. Above code gets stuck at password input. What needs to be done to pass through the password and getting into the Zoho Home Page.

Error Stack:

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Exception in thread "main" org.openqa.selenium.ElementNotInteractableException: element not interactable
  (Session info: chrome=115.0.5790.171)
Build info: version: '4.11.0', revision: '040bc5406b'
System info: os.name: 'Windows 11', os.arch: 'amd64', os.version: '10.0', java.version: '19.0.2'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [72e70cf8cb751141dce9053c2c87e0bf, sendKeysToElement {id=3451A97A48F2087285C0D569311DB6CC_element_39, value=[Ljava.lang.CharSequence;@2015b2cd}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 115.0.5790.171, chrome: {chromedriverVersion: 115.0.5790.170 (cc0d30c2ca5..., userDataDir: C:\Users\VARSHA~1\AppData\L...}, goog:chromeOptions: {debuggerAddress: localhost:64501}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: windows, proxy: Proxy(), se:cdp: ws://localhost:64501/devtoo..., se:cdpVersion: 115.0.5790.171, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
Element: [[ChromeDriver: chrome on windows (72e70cf8cb751141dce9053c2c87e0bf)] -> xpath: //input[@id='password']]
Session ID: 72e70cf8cb751141dce9053c2c87e0bf
    at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:484)
    at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:200)
    at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:133)
    at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:52)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:191)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:196)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:171)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:518)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:224)
    at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:111)
    at testcase.MyFirstTest.main(MyFirstTest.java:26)
Shawn
  • 4,064
  • 2
  • 11
  • 23
Tester
  • 1
  • 1
  • Add a web driver wait for an element to present, PF below code for your reference. WebDriverWait w=new WebDriverWait(driver, seconds) wait.presenceOfElementLocated(driver. find element (By.xpath("")); – Bhairu Aug 03 '23 at 11:57
  • Can you edit the question and add the error stack? – Shawn Aug 03 '23 at 12:01
  • @Shawn: please check the error stack added. – Tester Aug 11 '23 at 11:02

2 Answers2

0

As far as after entering login you have page loading state, you need to wait until password input is visible.

Try to login, using code below:

WebDriverWait wdwait = new WebDriverWait(driver, 10);
driver.get("https://www.zoho.com/");
driver.findElement(By.linkText("Sign in")).click();
driver.findElement(By.id("login_id")).sendKeys("email");
driver.findElement(By.xpath("//span[normalize-space()='Next']")).click();
wdwait.until(ExpectedConditions.visibilityOfElementLocated(new By.ByXPath("//input[@id='password']"))).sendKeys("password");
driver.findElement(By.id("nextbtn")).click();
Yaroslavm
  • 1,762
  • 2
  • 7
  • 15
0

Ideally to send a character sequence to the Email address or mobile number field and password within the website Zoho Accounts, as the elements are dynamic elements you need to induce WebDriverWait for the elementToBeClickable() and you can use either of the following locator strategies:

driver.get("https://www.zoho.com/");
new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.linkText("Sign in"))).click();
new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input#login_id"))).sendKeys("Tester@stackoverflow.com");
driver.findElement(By.xpath("//span[text()='Next']")).click();
new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input#password"))).sendKeys("Tester");
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352