0

Hello Stackoverflow community,

I am working with selenium IDE and I have the following problem: I have to move a web content within a web content Management System from one folder to another. Therefore I have to click on a "Select" button to specify a target folder, then an iframe opens up where I can navigate through the "tree structure" of the folders.
The original page looks like this:
original page with "Select"-button

enter image description here The structure of the web content management system is as follows: Home

-Test(=Parent Folder):  
        -UniqueTitle  
        -UniqueTitle2  

Because the folder that I want to adress(UniqueTitle2) lies one hierarchy below my current folder(I am in UniqueTitle), I have to click on the parent Folder "TEST" to go one hierarchy back. This is a link to the "TEST"-folder.

iframe where you can select the target folder

enter image description here

The problem is that on the original page below the iframe, the same Link to the "TEST"-folder exists as a breadcrumb. So if selenium clicks on the href link, it actually clicks the link on the original page, and not the one in the iframe.

I tried the following: to select the iframe:

storeAttribute|css=iframe.dialog-iframe-node@id|iframeIDE
selectFrame|id=${iframeID}

to click on the link:

clickAndWait|link=TEST

clickAndWait|//a[contains(@href,'https://www.companyname.com/language/projectname/manage/maintenance/web-content-management[...]folderid=465576')]

Here is a HTML Snippet of the iframe:

<a href="https://www.companyname.com/language/projectname/manage/maintenance/web-content-management?p_p_id=15&amp;p_p_lifecycle=0&amp;p_p_state=pop_up&amp;p_p_mode=view&amp;_15_struts_action=%2Fjournal%2Fselect_folder&amp;_15_folderId=4655761" data-direction-right="true" data-folder-id="4655761">TEST</a>

How can I differentiate between these two, so my script will click within the iframe?

Thank you in advance and let me know if you need more information.

Suneel Kumar
  • 1,650
  • 2
  • 21
  • 31
NoobDev
  • 1
  • 3

2 Answers2

0

you have two options:

1. don't use iframe, use div or section instead

using this approach, you have to move the code for file selection to the main page. use AJAX to populate the file list to the div. this approach is often called single page application, though you don't need to move everything to a single page, just the file selection codes.

2. set allow-origin header of your iframe to your domain name or *

you should read about how to set this HTTP header. here are some refs

Community
  • 1
  • 1
am05mhz
  • 2,727
  • 2
  • 23
  • 37
0

Probably duplicate of How to switch between frames in Selenium WebDriver using Java

First thing when you want to do something inside iframe is switch to it.

WebDriver.SwitchTo().Frame(WebDriver.FindElement(By.Id("iframe")));

After that you can click on element. When you want to back you can use:

WebDriver.SwitchTo().DefaultContent();
tomasz.myszka
  • 101
  • 1
  • 5