function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Soheil A.Soheil A. 

Salesforce lookup popup "searchFrame" not found in Silenium

Hi All, 

i have tried now several solutions available in the net related to my below problem without a success. Now came to the idea to use the community for the first time! :) 

This is my problem: 
I am using Silenium (Java framework) with Eclipse to test salesforce in automated frontend testing. I read that even salesforce doest that too. But strangely i cannot access the lookup popup (which is shown when you click on any lookup button) through silenium. 

With this i have tried to "debug" what is inside the frame: 
List<WebElement> ele = webDriver.findElements(By.tagName("frame"));
// show how many frames are defined with the tag "frame"
            System.out.println("Number of frames in a page :" + ele.size());
            for(WebElement el : ele){
              //Returns the Id of a frame.
                System.out.println("Frame Id :" + el.getAttribute("id"));
              //Returns the Name of a frame.
                System.out.println("Frame name :" + el.getAttribute("name"));
}

Result: "Number of frames in a page : 0"

Second Solution (with no success):
webDriver.switchTo().defaultContent();
// find the new popup window that i have opened previously with the lookup button
webDriver.switchTo().frame("searchFrame");
// find the search field in the new dialog box
WebElement element = webDriver.findElement(By.id("lksrch"));
element.sendKeys("my Company Name to use in popup");

Can anyone tell me how salesforce does that? Or what i am doing wrong? 

Bye
Soheil
Best Answer chosen by Soheil A.
NagendraNagendra (Salesforce Developers) 

All Answers

NagendraNagendra (Salesforce Developers) 
This was selected as the best answer
Soheil A.Soheil A.
Hi Nagendra, 

thanks. now i have the solution. It looks like this: 

First you need to switch to the window with the popup: 
public void switchToWindow(String windowName) {
        // TODO Auto-generated method stub

        WebDriver popup = webDriver;
        Set<String> windowIterator = webDriver.getWindowHandles();

        System.err.println("No of windows :  " + windowIterator.size());
      
        for (String s : windowIterator) {
            String windowHandle = s;
            popup = webDriver.switchTo().window(windowHandle);
            System.out.println("Window Title : " + popup.getTitle());
            System.out.println("Window Url : " + popup.getCurrentUrl());
      
            if (popup.getTitle().contains(windowName)) {
                System.out.println("Selected Window Title : " + popup.getTitle());
                webDriver = popup;
                break;
            }
        }
    }

and second switch to the frame: 
 
webDriver.switchTo().frame("searchFrame");

Third: 
but if you are in a nested frame (e.g. searchframe) and you want to search within the same window but another frame you need to go up or out again with this to switch to the resultsFrame: 
 
webDriver.switchTo().defaultContent();
webDriver.switchTo().parentFrame();
webDriver.switchTo().frame("resultsFrame");

 
NagendraNagendra (Salesforce Developers) 
Hi Sohail,

I am glad that you have found the solution for the above problem.May I suggest you please mark this as solved so that others may get benefitted out of it.

Regards,
Nagendra.
Smita LokhandeSmita Lokhande
Hi Sohail,
I am facing same issue which you mentioned above. but you have to click on looup and enter something to get popup results how do u did it? as I also tried all possible ways to click on lookup field and tried to send data to it. but nothing worked.
Please suggest