I trying to get BoundingBoxAsync of element but faced error that frame not found. But this element located in another frame, so I don’t understand how to fix this problem, may be anyone can help me
My code:
foreach (var frame in page.Frames)
{
Console.WriteLine(frame.Id);
var elements = await frame.XPathAsync(".//select[@id='select']");
Console.WriteLine("elements.Length in frame "+frame.Id+" = " + elements.Length);
if (elements.Length > 0)
{
var boundingBox = await elements[0].BoundingBoxAsync();
if (boundingBox != null)
{
Console.WriteLine($"Frame URL: {frame.Url}");
Console.WriteLine($"X: {boundingBox.X}");
Console.WriteLine($"Y: {boundingBox.Y}");
Console.WriteLine($"Width: {boundingBox.Width}");
Console.WriteLine($"Height: {boundingBox.Height}");
break;
}
}
}
Result of my code:
444398C884B7D228CE4744687E417C6E
elements.Length in frame 444398C884B7D228CE4744687E417C6E = 0
3DB4AC94A94EE8E6EA6DE6CAC34C7D82
elements.Length in frame 3DB4AC94A94EE8E6EA6DE6CAC34C7D82 = 1
Frame 8876375E8F13B2900CD53AFACF5D449E not found
So I dont understand where puppeteer take frame 8876375E8F13B2900CD53AFACF5D449E because my page have only frame 444398C884B7D228CE4744687E417C6E and 3DB4AC94A94EE8E6EA6DE6CAC34C7D82…
And element located in 3DB4AC94A94EE8E6EA6DE6CAC34C7D82, but when I try to do BoundingBoxAsync on this element I faced this error