Open yugal-compro opened 1 year ago
Sorry for the confusion in the docs, the "ID" referred isn't the frame ID in the DOM, it's the dev tools ID for the execution context. If you look at the JSON result of a test it will have the list of all of the execution contexts with the ID's and origins.
I'm pretty sure the execution context's are just sequentially numbered but you'll want to verify the ID in the JSON
FWIW, for that pen, these are the execution context ID's and origins (at least when tested with desktop):
"execution_contexts": [
{
"id": 2,
"origin": "https:\/\/cdpn.io",
"name": ""
},
{
"id": 1,
"origin": "https:\/\/codepen.io",
"name": ""
},
{
"id": 3,
"origin": "https:\/\/codepen.io",
"name": ""
},
{
"id": 5,
"origin": "https:\/\/js.stripe.com",
"name": ""
},
{
"id": 6,
"origin": "https:\/\/m.stripe.network",
"name": ""
}
],
It looks like the 2 stripe origins are actually different so you could probably use the named origin as well.
Thanks for your response, I tried setting the execution context using the ID given in the JSON result still, this is not changing the execution context
There is a type mismatch when setting context by id key.
You are comparing string with integer which results in false here: https://github.com/WPO-Foundation/wptagent/blob/eb86253f0e27463a9ccf2268d41f13e370f7a1bc/internal/devtools.py#L1250
Setting by origin works ok, see here: https://www.webpagetest.org/result/230629_AiDcS7_6GB/ Setting by id fails, see here: https://www.webpagetest.org/result/230629_AiDc1W_6GC/
Here are the contexts from JSON:
"execution_contexts":
[
{
"id": 2,
"origin": "https://cdpn.io",
"name": ""
},
{
"id": 1,
"origin": "https://codepen.io",
"name": ""
},
{
"id": 3,
"origin": "https://codepen.io",
"name": ""
},
{
"id": 5,
"origin": "https://js.stripe.com",
"name": ""
},
{
"id": 6,
"origin": "https://m.stripe.network",
"name": ""
}
]
So for now setting context by id is impossible. Could you fix this please? Thx in advance 😄
For a temporary workaround you can use jQuery for switching to another frame (same origin only):
execAndWait $("#content-iframe").contents().find("#Assessments_Navigation_Bar1 .section_0 .button")[0].click()
Is the fix released yet?
It still works by origin
:
https://www.webpagetest.org/result/230724_AiDcZ6_BRQ/
But not yet with id
:
Doesn't look like it. The prod branch hasn't been updated since the fix landed.
Use Case:
I would like to change the execution context using Id of the iframe
I referred to the documentation https://docs.webpagetest.org/scripting/#setexecutioncontext for switching the execution context and was able to switch it using origin but was unable to switch the execution context using the ID of the cross-origin iframe.
Script:
Expected Action:
Issue Faced: The input value is not updating to 'Yugal Vashishth' This script works fine when I change the execution context using the 'origin' of the iframe but It doesn't work when I use the 'ID' of the iframe.
Note: I am using ID instead of origin because I have to access two iframes having the same origin, so when I set the execution context using 'origin' it always returns the execution context of the first iframe but I would also like to access the second iframe.