Unable to enter email id and password...Copied below are the script and the error | Selenium Forum
S
Sonia Negi Posted on 23/11/2019

----Driver Script

package com.qtpselenium.rediff.driver;

 

import com.qtpselenium.rediff.keywords.ApplicationKeywords;

import com.qtpselenium.rediff.utill.Xls_Reader;

 

public class Driverscript {

 

public static void main(String[] args) {

// TODO Auto-generated method stub

 

String testname = "LoginTest";

String path = System.getProperty("user.dir")+"/TestCases.xlsx";

Xls_Reader xls = new Xls_Reader(path);

int rows = xls.getRowCount("Keywords");

System.out.println("Total Rows---" + rows);

 

ApplicationKeywords app = new ApplicationKeywords();

for(int rnum = 2 ; rnum<=rows;rnum++) {

 

String tcid = xls.getCellData("Keywords", "TCID", rnum);

if(testname.equals(tcid)) {

String keyword = xls.getCellData("Keywords", "Keyword", rnum);

String object = xls.getCellData("Keywords", "Object", rnum);

String data = xls.getCellData("Keywords", "DATA", rnum);

//System.out.println(tcid +"-----"+keyword +"----"+object+"------"+data);

if(keyword.equals("openBrowser"))

app.openBrowser(data);

else if(keyword.equals("navigate"))

app.navigate(object);

else if(keyword.equals("type"))

app.type(object,data);

else if(keyword.equals("click"))

app.click(object);

else if(keyword.equals("verifyTitle"))

app.verifyTitle();

else if(keyword.equals("verifyElementPresent"))

app.verifyElementPresent();

else if(keyword.equals("verifylogin"))

app.verifylogin();

}

 

}

}

 

}

-----GenericKeywords script

package com.qtpselenium.rediff.keywords;

 

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.support.ui.ExpectedConditions;

import org.openqa.selenium.support.ui.WebDriverWait;

 

public class GenericKeywords {

 

WebDriver driver = null ;

 

 

public void openBrowser(String browserName) {

System.out.println("Opening Browser "+browserName);

 

if(browserName.equals("Chrome"))

System.setProperty("webdriver.chrome.driver", "/Users/snegi/Desktop/EclipseIDE/Hybrid_Framework_Oct19_1/chromedriver");

driver = new  ChromeDriver();

 

 

driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);

 

}

public void navigate(String url) {

System.out.println("Navigating to URL"+url);

driver.get(url);

}

public void type(String object,String data) {

System.out.println("Typing in object"+object+". Data is"+ data);

getObject(object).sendKeys(data);

}

public void click(String object) {

System.out.println("Clicking on button "+object);

getObject(object).click();

}

public WebElement getObject(String object) {

 

WebElement e = null;

 

try {

 

//presence

 

e = driver.findElement(By.xpath(object));

 

//intractable

 

WebDriverWait wait = new WebDriverWait(driver, 10);

 

wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath(object)));

 

}catch(Exception ex) {

 

}

 

return e;

 

}

 

}

------Script ERROR 

Total Rows---20

Opening Browser

Starting ChromeDriver 77.0.3865.40 (f484704e052e0b556f8030b65b953dce96503217-refs/branch-heads/3865@{#442}) on port 42795

Only local connections are allowed.

Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.

[1574511144.009][WARNING]: This version of ChromeDriver has not been tested with Chrome version 78.

Nov 23, 2019 5:42:24 PM org.openqa.selenium.remote.ProtocolHandshake createSession

INFO: Detected dialect: W3C

Navigating to URLhttps://portfolio.rediff.com/portfolio-login

Validating title

Typing in object//input[@id='useremail']. Data is

Clicking on button //input[@id='emailsubmit']

Typing in object//input[@id='userpass']. Data is

Exception in thread "main" org.openqa.selenium.ElementNotInteractableException: element not interactable

  (Session info: chrome=78.0.3904.108)

Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'

System info: host: 'BAN7167.local', ip: 'fe80:0:0:0:1c42:baad:d504:1586%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '10.0.2'

Driver info: org.openqa.selenium.chrome.ChromeDriver

Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 78.0.3904.108, chrome: {chromedriverVersion: 77.0.3865.40 (f484704e052e0..., userDataDir: /var/folders/lp/sq8twhh55d7...}, goog:chromeOptions: {debuggerAddress: localhost:53472}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}

Session ID: 2a14db272bab903658c1ff8c7cc1e990

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:488)

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)

at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)

at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)

at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)

at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)

at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)

at org.openqa.selenium.remote.RemoteWebElement.sendKeys(RemoteWebElement.java:106)

at com.qtpselenium.rediff.keywords.GenericKeywords.type(GenericKeywords.java:35)

at com.qtpselenium.rediff.driver.Driverscript.main(Driverscript.java:31)


A
Ashish Thakur Replied on 25/11/2019

The password field takes some time to be visible

May be 1 sec and before that selenium tries to find it

Please give a little delay

OR use explicit wait to check if element is visible