I want to send keys to Card Number, Expiration Date and CVV text fields which are in iframe.
Now what I observed is, when in the test case, whichever frame I write first to switch is located and the keys are sent and other two are ignored.
In below code, I mentioned expiration date frame first which is located but the card frame i.e. cddnumber id frame is not found.
cpp.fillintextfields.get(4).sendKeys("test@test.com");
WebElement es = driver1.findElement(By.id("CollectJSInlineccexp"));
driver1.switchTo().frame(es);
cpp.expdate.sendKeys("01/21");
driver1.switchTo().frame("CollectJSInlineccnumber");
Thread.sleep(2000);
cpp.cdnumber.sendKeys("4111111111111111");
Thread.sleep(5000);
Now when I mention cddnumber i.e. card number frame first as in code below and expiration date frame after that, card number frame is located and expiration date ones is not located.
cpp.fillintextfields.get(4).sendKeys("test@test.com");
driver1.switchTo().frame("CollectJSInlineccnumber");
Thread.sleep(2000);
cpp.cdnumber.sendKeys("4111111111111111");
Thread.sleep(5000);
WebElement es = driver1.findElement(By.id("CollectJSInlineccexp"));
driver1.switchTo().frame(es);
cpp.expdate.sendKeys("01/21");
Following are the TestNG traces of error given in short when I mention expiry date frame before card number frame:
org.openqa.selenium.NoSuchFrameException: No frame element found by name or id CollectJSInlineccnumber
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'KE5', ip: '10.6.6.105', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '10.0.2'
Driver info: driver.version: unknown
at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.frame(RemoteWebDriver.java:885)
Please help me and suggest me any solution to tackle this issue so that all the frames can be located even though I write them one after the other.