Reputation: 55
I'm using selenium webdriver with javascript on Chrome and I'm trying to interact with an input inside an iframe like so:
await driver.switchTo().frame(By.xpath('/html/body/div[1]/div/div/form/ng-form/div/ui-view/div/dqcomponent[3]/ng-form/div[1]/div[1]/iframe/html/body/form/input[1]'));
I am able to use .click()
on the element just fine but the above line causes the following error:
(node:4514) UnhandledPromiseRejectionWarning: InvalidArgumentError: invalid argument: missing 'ELEMENT'
I have tried switching to the element using CSS but it produces the same error, how can I properly switch to said iframe?
My webdriver version is ^4.0.0-beta.1
and my chrome driver is ^88.0.0"
Upvotes: 3
Views: 4149
Reputation: 19929
await driver.switchTo().frame expects an element not locator
Use it like
Elem = await driver.findElement(By.id("some if"))
await driver.switchTo().frame(Elem)
Upvotes: 3