TestProject Forum

New "Failed to switch driver context to..." error for iframe elements

Using Chrome 93.0.4577.63 and Windows Agent v3.2.0, I am seeing the following error for tests attempting to locate elements within an iframe (the actual xpath location is redacted here and throughout):

Metadata: [Message]: Failed to switch driver context to XPATH = <xpath_location>

Using Chrome 92.0.4515.131 and Windows Agent v3.1.0 I could get the same job to pass. I haven’t edited the tests inbetween runs.

In a brand new test using the smart web recorder, I’ve attempted the following:

  • locate the iframe in locator (reportedly a Generic Web Element), create a new element and add a “Switch to iFrame” step with it, using the Element Extensions addon. This passes.
  • select a present div inside an iframe → Validations → “Is Present?”, this creates a test step
  • run that newly created test step, it fails with:

Failed to switch driver context to {{XPATH = /<xpath_location>

I see this error whether I run the “switch to iframe” step or not. I didn’t need this step when my tests passed a month ago on v3.1.0. I can locate the elements in the iframe manually using their css selectors, xpaths etc.

I have searched the docs (and this forum) for this error. I can’t make use of these docs because I can’t use ID as a locator option.

I’d appreciate any help I could get on this! Has something changed recently with switching context and handling iframes?

@heather_uhs please upgrade to agent 3.3.0 and let me know if that solves your issue.

1 Like