Search code examples
iframeselenium-chromedriverrobotframework

How to select an iFrame witth Dynamic ID with robot framework in PyCharm please?


Here is the iframe

<iframe src="User/UserAccounts" id="7969e06b-e259-82e7-ee38-fdac0a745e4a_iframe" frameborder="0" marginwidth="10" style="width: 823px; height: 744px;" onload="setTimeout(SSWindow.DocumentReady('#7969e06b-e259-82e7-ee38-fdac0a745e4a_iframe'), 20);"></iframe>

id="7969e06b-e259-82e7-ee38-fdac0a745e4a_iframe

7969e06b-e259-82e7-ee38-fdac0a745e4a = this part is changing every reload

I Tried the below but it doesn't work. //span[@class='bodyIframe'] //span[contains(text(),'_Iframe')]


Solution

  • Any other attribute also could be used if its value is unique and constant over reloadings.

    E.g. src attribute with the value "User/UserAccounts" probably could be useful here.

    And respectively using keyword select frame to select frame if you use library SeleniumLibrary. For example:

    Select frame  //iframe[@src="User/UserAccounts"]