Please check my program | Selenium Training|Java|WebDriver|TestNG|Frameworks|Videos
10% April Month Discount Avail now

Selenium Training Forum

Please check my program

N
Neha Bansal Post on 01/04/2019

I am tring to select the required date in my calender but I am getting error. I have pasted console track in the image and attached the java file.

Thanks

D

Instructor

Demo Reply on 02/04/2019

I do not see attachment

N
Neha Bansal Reply on 03/04/2019

Starting ChromeDriver 73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72) on port 11018
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
Apr 03, 2019 4:11:49 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
1969 - 1980
04
05
2008
1981 - 1992
1993 - 2004
2005 - 2016
Exception in thread "main" org.openqa.selenium.ElementNotVisibleException: element not interactable
(Session info: chrome=73.0.3683.86)
(Driver info: chromedriver=73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72),platform=Mac OS X 10.14.4 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: 'IDCMBP067.local', ip: 'fe80:0:0:0:142e:7063:b83a:4277%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.4', java.version: '1.8.0_101'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 73.0.3683.68 (47787ec04b6e3..., userDataDir: /var/folders/1l/6hjx1pyn591...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:54823}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, proxy: Proxy(), rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 73.0.3683.86, webStorageEnabled: true}
Session ID: ac9e20205d16ae70e3053f282732ec94
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
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.click(RemoteWebElement.java:84)
at Loan_Icici_Exercise.main(Loan_Icici_Exercise.java:66)

D

Instructor

Demo Reply on 09/04/2019

Please make sure that the element you are trying to access is available at the moment.

 

A
Avinash Vijaykumar Mahamuni Reply on 09/04/2019

//try with this codeit will work //

 

//i edited the only the date format of month and the xpath for the month and added the thread.sleep(1000).

 

public static void main(String[] args) throws ParseException, InterruptedException {

System.setProperty("webdriver.chrome.driver","/Users/avinash/Documents/BrowserExeFiles/chromedriver");

WebDriver driver= new ChromeDriver();

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

driver.get("https://loan.icicibank.com/asset-portal/auto-loan/check-eligibility?WT.mc_id=Desk_NLI_ProductPage_ApplyNow");

 

// //Select the drop down for type of loan

// driver.findElement(By.xpath("//*[@id='check-eligibility-page']/div[4]/div/div/form/div[2]/div[1]/div/div/button/span[1]")).click();

// driver.findElement(By.xpath("//span[text()='Balance transfer']")).click();

// //Mobile number

// driver.findElement(By.name("mobileNumber")).sendKeys("9874561232");

// //current address

// driver.findElement(By.xpath("//div[@class='custom-date-holder location-drpdwn map']/span[@class='input input--hoshi']/input")).sendKeys("Del");

// driver.findElement(By.xpath("//li[starts-with(@id,\'typeahead-')]/a")).click();

// //Residence owned

// driver.findElement(By.xpath("//*[@id=\"check-eligibility-page\"]/div[4]/div/div/form/div[5]/div[2]/div/div/button/span[1]")).click();

// driver.findElement(By.xpath("//span[text()='Owned']")).click();

 

// Calendar

driver.findElement(By.xpath("//span[@class='input__label-content pull-right ng-scope']/img")).click();  //Clicking on the calendar icon

String date= "04/05/2008";

//String month="May";

String yearRange= driver.findElement(By.xpath("//th[@colspan='2']/button[starts-with(@id,'datepicker-')]/strong")).getText();

System.out.println(yearRange);   //1969-1980

 

SimpleDateFormat sd = new SimpleDateFormat("dd/MM/yyyy");

Date dateToBeSelected= sd.parse(date);

sd = new SimpleDateFormat("dd");

String dayToBeSelected = sd.format(dateToBeSelected);

sd = new SimpleDateFormat("MMMM");

String monthToBeSelected = sd.format(dateToBeSelected);

sd = new SimpleDateFormat("yyyy");

int yearToBeSelected = Integer.parseInt(sd.format(dateToBeSelected));

System.out.println(dayToBeSelected);

System.out.println(monthToBeSelected);

System.out.println(yearToBeSelected);

//logic to reach the required year

while(true) {

Thread.sleep(2000);

String temp[] = yearRange.split(" - ");

if (yearToBeSelected <= Integer.parseInt(temp[1]) & yearToBeSelected >= Integer.parseInt(temp[0])) {

break;

 

}else if(yearToBeSelected < Integer.parseInt(temp[0])) {

driver.findElement(By.xpath("div[@class='uib-datepicker ng-isolate-scope']/table/thead/tr/th/button")).click();

//Click on back arrow

} else if (yearToBeSelected > Integer.parseInt(temp[1])) {

driver.findElement(By.xpath("//div[@class='uib-datepicker ng-isolate-scope']/table/thead/tr/th[3]/button")).click();

//forward arrow

        }

yearRange = driver.findElement(By.xpath("//th[@colspan='2']/button[starts-with(@id,'datepicker-')]/strong")).getText();

System.out.println(yearRange);

}

driver.findElement(By.xpath("//span[text()='"+yearToBeSelected+"']")).click();

//Thread.sleep(2000);

driver.findElement(By.xpath("//button[@class='btn btn-default']/span[text()='"+monthToBeSelected+"']")).click();

driver.findElement(By.xpath("//span[text()='"+dayToBeSelected+"']")).click();

}

D

Instructor

Demo Reply on 10/04/2019

The ElementNotVisibleException: element not interactable exception comes up whenever the code is not able to see the element you would want to access.

A
Avinash Vijaykumar Mahamuni Reply on 10/04/2019

Then we need to scroll the page.for that we need to use javascript executor.

D

Instructor

Demo Reply on 13/04/2019

Neha, Is the issue resolved?

N
Neha Bansal Reply on 15/04/2019

Yes, it is resolved now. 

Thanks