简体   繁体   中英

Action on SharePoint New Item form in selenium 2 using C# is not working

I am trying to automate sharepoint site new item form but what ever method i try it is showing not found.

I tried switchTo() to a new iframe, window...

Tried this code which finds the outer content

IWebElement table1 = WebElement.FindElement(By.XPath("//table[@class=\"s4-wpTopTable\"]"));
int table1count = WebElement.FindElements(By.XPath("//table[@class=\"s4-wpTopTable\"]")).Count;
MessageBox.Show(table1count.ToString());

above code displays the table count as 2. Going beyond this element does not show any element.

And I am using IE as the browser.

使用Firebug的HTML结构

I used Xpath and could identify till the red mark and it does not identify beyond that.. i am trying to identify the elements marked in green.

var iframecount = driver.FindElement(By.XPath("//html/body/form/div[8]/div/div[4]/div[2]/div[2]/div/div/table/tbody/tr/td

Here is the xpath is used taken from FireBug

var iframecount = driver.FindElement(By.XPath("//html/body/form/div[8]/div/div[4]/div[2]/div[2]/div/div/table/tbody/tr/td/div/span/table/tbody/tr/td[2]/span/span/input"));

i have found answer for this... Sharepoint New item form (ie modal pop up) has 3 iframes without id or name so switching to iframe using the below code works

driver.SwitchTo().Frame(2);

ie frames start from 0 index.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM