How can I click and find elements inside an iframe?

  • Автор темы Автор темы cesario678
  • Дата начала Дата начала

cesario678

Client
Регистрация
10.03.2022
Сообщения
234
Реакции
14
Баллы
18
I’m having a problem with an iframe block here. I can’t seem to find its elements at all. I managed to find the element, but it never actually clicks.


Then I tried using an element outside the iframe: I get its coordinates and create a click at a position below or above that element. The problem is that the element is large, and sometimes the actual position where I need to click is not in the same place relative to that element. Sometimes it moves to a completely different location.


Does anyone have any tips or a way to find this element so I can click it? Is there some trick or technique that could help me figure this out?


Thank you!
 
Oh, and just to add: I also tried using image recognition to find and click the element. However, the buttons I need to click are transparent, and there are different colors and objects in the background, so image recognition never clicks the correct spot.
 
The information you provided is not enough to help.
We need examples of pages and elements with which problems arise.
Everything depends a lot on the context.
Now it is not a problem to send the DOM to AI and get the necessary XPath paths for clicks.
You need to click on pictures when there are no other ways.
And whether there are other ways - it is impossible to know without a site and the path you need to follow to repeat what you are doing.

Google Translate
 
The information you provided is not enough to help.
We need examples of pages and elements with which problems arise.
Everything depends a lot on the context.
Now it is not a problem to send the DOM to AI and get the necessary XPath paths for clicks.
You need to click on pictures when there are no other ways.
And whether there are other ways - it is impossible to know without a site and the path you need to follow to repeat what you are doing.

Google Translate
<div class="CDLayout2067515" style="...background-color: rgba(0,0,0,0.5)...">
<a href="https://vignoli.com/ghits/30356/..."
class="CDButton2067515"
style="...top: 58.01%; left: 29.28%...">Va</a>
</div>

This is what I need to click; I got it from the DOM.

So first I need to click somewhere on my website for it to appear, and then this “Va” button appears.

Do you have any other tips now on how I should create it in Rise Click so that it can click on that button? Or would there be another way to do it?
 
<div class="CDLayout2067515" style="...background-color: rgba(0,0,0,0.5)...">
<a href="https://vignoli.com/ghits/30356/..."
class="CDButton2067515"
style="...top: 58.01%; left: 29.28%...">Va</a>
</div>
This is roughly what you need:
Send to Gemini DOM.
Please give XPath
Then please use it for clicking in Zennoposter.
We get approximately the following code:
C#:
Развернуть Свернуть Копировать
var tab = instance.ActiveTab;
var button = tab.FindElementByXPath("//div[starts-with(@class, 'CDLayout')]//a[starts-with(@class, 'CDButton') and text()='Va']", 0);
if (!button.IsVoid) button.Click();
else throw new Exception("not button");

The code may not work - I just described the process.
Google Translate
 
  • Оценить
Реакции: cesario678
This is roughly what you need:
Send to Gemini DOM.
Please give XPath
Then please use it for clicking in Zennoposter.
We get approximately the following code:
C#:
Развернуть Свернуть Копировать
var tab = instance.ActiveTab;
var button = tab.FindElementByXPath("//div[starts-with(@class, 'CDLayout')]//a[starts-with(@class, 'CDButton') and text()='Va']", 0);
if (!button.IsVoid) button.Click();
else throw new Exception("not button");

The code may not work - I just described the process.
Google Translate
What I needed was quite difficult, but I managed it thanks to your tips—thank you.
 
  • Оценить
Реакции: BAZAg
I’m having a problem with an iframe block here. I can’t seem to find its elements at all. I managed to find the element, but it never actually clicks.


Then I tried using an element outside the iframe: I get its coordinates and create a click at a position below or above that element. The problem is that the element is large, and sometimes the actual position where I need to click is not in the same place relative to that element. Sometimes it moves to a completely different location.


Does anyone have any tips or a way to find this element so I can click it? Is there some trick or technique that could help me figure this out?


Thank you!
I’d avoid coordinate-based clicking if possible. It tends to become unreliable as soon as the iframe moves, resizes, or the page layout changes.


The first thing I’d check is whether you’re actually switching into the correct iframe context before searching for the element. If there are nested iframes, you may need to walk through the full frame hierarchy rather than trying to access the final element directly from the main document.


I’d also inspect whether the iframe is cross-domain. In that case normal DOM access can behave differently or be restricted, depending on how ZennoPoster handles the page.


Another thing worth trying is locating the iframe itself first, waiting until it has fully loaded, and only then searching for the child element. Sometimes the element exists but the action is firing before the frame content is ready.


For the transparent buttons, instead of image recognition I’d try using stable attributes, text from a parent/container, XPath/CSS selectors, or JavaScript inside the frame if ZennoPoster allows it. You can also temporarily highlight the target element with JavaScript or log its bounding rectangle to confirm that you’re finding the correct node.


If the element is found but the click still does nothing, I’d test whether a normal DOM click, JavaScript click(), and a physical mouse click behave differently. Some sites only react properly to real pointer events.
 
  • Оценить
Реакции: cesario678

Кто просматривает тему: (Всего: 0, Пользователи: 0, Гости: 0)