Currently, I am facing an issue where I am attempting to enter text into an input field. However, I have noticed that there are two elements with the same id name and I need guidance on specifying which specific div -> input I want to interact with.
Here is what I have tried so far:
it('Entering First Name', function (done) {
browser.driver
.then(() => browser.wait(EC.visibilityOf(element(by.xpath('//input[@id="pp-cc-first-name-field"]'))), 50000, "Timed out finding 'First Name' element"))
.then(() => element(by.xpath('//input[@id="pp-cc-first-name-field"]')).sendKeys("hello world")
.then(() => done());
});
This is the HTML structure being used:
https://i.sstatic.net/7KYjH.png
At this point, I am unsure about the mistake I might be making as the input operation fails due to a timeout. My goal is to successfully input text into this particular element.
UPDATE!
After further investigation, it appears that I needed to switch to an iframe because there was an iframe loaded in the background preventing me from entering text into the field. I had to use
browser.switchTo().frame(element(by.xpath("//iframe[@id='cc-integrated-payment-page-frame']")).getWebElement()))
in order to successfully input text into the fields.