AlanD
AlanD

Reputation: 55

Unable to locate element in SharePoint popup window

I'm having trouble with finding an element when I want to create a new page in Sharepoint 2010. I'm exporting my testcase from Selenium IDE Java / Junit 4 WebDriver into eclipse.

Here's how the pop-up window looks like: https://i.sstatic.net/Y29KW.jpg

I´ve tried many different element locators and combinations like: Xpath, Csselector, Id, Name and none of them seems to be able to find the input field.

Why is it like this?

I´ve tried with ExplicitWait and Implicit but that does not seem to solve my problem.

Here's where it gets stuck:

try{
        assertTrue(isElementPresent(By.cssSelector("#ctl00_PlaceHolderMain_nameInput")));
    }
    catch(Error e) {
        verificationErrors.append(e.toString());
    }


    driver.findElement(By.xpath(".//*[@id='ctl00_PlaceHolderMain_nameInput']")).click();

Thanks in advance. :)

Upvotes: 1

Views: 310

Answers (1)

Thriggle
Thriggle

Reputation: 7059

Popup windows in SharePoint 2010 are usually iframes with embedded pages.

If you can obtain a reference to the iframe, you can then query the embedded page using the iframe's contentDocument property.

For example, if your iframe has a class name of ms-dlgFrame, and the text input control has an ID of ctl00_PlaceHolderMain_nameInput, you can use the following JavaScript to select the input textbox:

document.querySelector(".ms-dlgFrame").contentDocument.querySelector("#ctl00_PlaceHolderMain_nameInput")

Upvotes: 1

Related Questions