Open telppa opened 1 month ago
Thank you. I would have implemented frame switching from CDP but webdriver has it own apis to deal with them bit complicated but the issue is when you switch the frame from CDP it is not switched for driver we can target specific frame by using CDPcall and extract frame tree. but not all web pages designed same.
btw Long ago when I was learning AHK classes I worked on Devtool protocols Chrome.ahk DOM Wrapper, It has the ability to get the whole tree of frame you might find it useful, there I just try to simplyfy the chrome.ahk use for example
Page := chrome.GetPageByURL("https://webflow.com/blog/business-website-examples","contains")
Document := New DOM(Page)
id := "w-node-_924b83c0-f4ca-a978-eee8-5ff56c41a20f-b19772d1"
e := Document.getelementbyid(id)
msgbox, % "TextContent:`n" e.TextContent "`n`nInnerText:`n" e.InnerText
e := e.querySelector("h1")
e.InnerText := "123456" ; setting new innerText
thank you.
i have a new question, this is your code in cdp.ahk
Frame(i)
{
frameId := this.childFrames[i +1].frame.id
this.ParentNodeID := this.Nodeid
if frameId
{
nodeid := this.call("DOM.getFrameOwner",{"frameId":frameId}).nodeid
backendNodeId := this.call("DOM.describeNode",{"nodeId":nodeid}).node.contentDocument.backendNodeId
contentDocObject := this.call("DOM.resolveNode",{"backendNodeId":backendNodeId}).object.objectId
this.nodeid := this.call("DOM.requestNode",{"objectId":contentDocObject}).nodeId
}
}
Frame(i)
{
frameId := this.childFrames[i +1].frame.id
this.ParentNodeID := this.Nodeid
if frameId
{
this.nodeid := this.call("DOM.getFrameOwner",{"frameId":frameId}).nodeid
}
}
I experimented and found that the first method of getting the frame's nodeid was correct, but I couldn't understand why the second method of getting the nodeid wouldn't work properly.
I am not professional I just read chome Devtool protocols and figure that out, and this is what I understand.
there DOM inside a DOM both dom has their own nodeId, first method reading the frame id and then approaches to the DOM inside and get document (contentDocument) nodeid within the frame,
see backendNodeId := this.call("DOM.describeNode",{"nodeId":nodeid}).node.contentDocument.backendNodeId
there is 'contentDocument' which does not offer nodeid so we inquire for objectid using backendnodeid and from object id we inquire and get the nodeid
second method its get the nodeid of that frame ....
https://github.com/telppa/Chrome.ahk-plus
Significantly simplifies the manipulation of elements and frames.
I don't know how to merge these improvements into your project, but maybe you're interested as well.
Example for TAB/Page 1
Example for TAB/Page 1