本文整理匯總了C#中WatiN.Core.IE.Table方法的典型用法代碼示例。如果您正苦於以下問題:C# IE.Table方法的具體用法?C# IE.Table怎麽用?C# IE.Table使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類WatiN.Core.IE
的用法示例。
在下文中一共展示了IE.Table方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: DeletePostByTitle
public bool DeletePostByTitle(string title, IE ie)
{
ie.GoTo(Url);
ie.WaitForComplete();
var tblPosts = ie.Table("Posts");
if (tblPosts != null)
{
foreach (var row in tblPosts.TableRows)
{
if (!string.IsNullOrEmpty(row.Id) && row.InnerHtml.Contains(title))
{
ie.Link("a-" + row.Id).Click();
return true;
}
}
}
return false;
}
示例2: FetchLeetCode
public void FetchLeetCode()
{
using (var browser = new IE("https://leetcode.com"))
{
using (StreamReader sr = new StreamReader(Directory + @"template\solution.html"))
{
string solutionTemplate = sr.ReadToEnd();
using (StreamReader questionReader = new StreamReader(Directory + @"template\question.html"))
{
string questionTemplate = questionReader.ReadToEnd();
var toHtml = new IE("http://hilite.me/");
browser.Link(Find.ByClass("btn btn-default")).Click();
browser.TextField(Find.ById("id_login")).SetAttributeValue("value", "[email protected]"); //TypeText("[email protected]");
browser.TextField(Find.ById("id_password")).SetAttributeValue("value", "Test123"); //.TypeText("Test123");
browser.Button(Find.ByText("Sign In")).Click();
for (int i = 115; i < 300; ++i)
{
var table = browser.Table(Find.ById("problemList"));
var body = table.TableBodies[0];
foreach (var row in body.OwnTableRows)
{
if (row.Elements != null && row.Elements.Count > 0 && "ac" == row.Elements[1].ClassName)
{
var cell2 = row.Elements[2] as TableCell;
string questionIndex = cell2.Text;
if (Int32.Parse(questionIndex) == i)
{
var cell = row.Elements[3] as TableCell;
string questionName = cell.Text;
cell.Links[0].Click();
var questionDiv = browser.Div(Find.ByClass("question-content"));
string questionContent = "";
for (int j = 0; j < questionDiv.Paras.Count; ++j)
{
if (!string.IsNullOrEmpty(questionDiv.Paras[j].Text) &&
questionDiv.Paras[j].Text.StartsWith("<b>Notes:</b>"))
{
break;
}
questionContent += "<p>" + questionDiv.Paras[j].Text + "</p>";
}
//browser.Links.SelectMany(l => l.Text == "My Submissions");
browser.Links.Filter(l => l.Text == "My Submissions").Where(l => l.Url != "https://leetcode.com/submissions/").First().Click();
//browser.Link(Find.ByText("My Submissions") ). .Click();
browser.WaitForComplete();
var tableResult = browser.Table(Find.ById("result_testcases"));
var resultBody = tableResult.TableBodies[0];
string solutionCode = "";
foreach (var resultRow in resultBody.OwnTableRows)
{
if (resultRow.Elements[3].Text.Contains("Accepted"))
{
var acceptedCell = resultRow.Elements[3] as TableCell;
acceptedCell.Links[0].Click();
var div = browser.Div(Find.ByClass("ace_content"));
solutionCode = div.Text;
solutionCode = solutionCode.Replace("\r\n\r\n", "\r\n");
break;
}
}
toHtml.TextField(Find.ById("divstyles")).SetAttributeValue("value", "padding:.1em .3em;");
toHtml.TextField(Find.ByName("code")).SetAttributeValue("value", solutionCode);
toHtml.SelectList(Find.ByName("lexer")).SelectByValue("cpp");
toHtml.Button(Find.ByValue("Highlight!")).Click();
toHtml.WaitForComplete(3);
string questionhtml = questionTemplate.Replace("<%QuestionName%>", questionName).Replace("<%QuestionContent%>", questionContent);
string solutonhtml = solutionTemplate.Replace("<%QuestionName%>", questionName).Replace("<%SolutionTemplate%>", toHtml.TextField(Find.ById("html")).Text);
solutonhtml = solutonhtml.Replace("margin: 0; line-height: 125%", "margin: 0; line-height: 125%; white-space: pre-wrap;");
string solutionFilename = Directory + "output\\" + questionIndex + ".solution.html";
string questionFileName = Directory + "output\\" + questionIndex + ".question.html";
System.IO.File.WriteAllText(solutionFilename, solutonhtml);
System.IO.File.WriteAllText(questionFileName, questionhtml);
browser.GoTo("https://leetcode.com/problemset/algorithms/");
}
}
}
//.........這裏部分代碼省略.........
示例3: FindControlInBrowserByID
public static object FindControlInBrowserByID(IE ie, string strID, Enumerators.ControlType ctrl)
{
if (ctrl == Enumerators.ControlType.Span)
{
Span sp = ie.Span(Find.ById(strID));
Assert.IsTrue(sp.Exists, "Could not Find: " + strID);
return sp;
}
else if (ctrl == Enumerators.ControlType.Link)
{
Link lnk = ie.Link(Find.ById(strID));
Assert.IsTrue(lnk.Exists, "Could not Find: " + strID);
return lnk;
}
else if (ctrl == Enumerators.ControlType.Frame)
{
Frame iFrame = ie.Frame(Find.ById(strID));
return iFrame;
}
else if (ctrl == Enumerators.ControlType.Image)
{
Image img = ie.Image(Find.ById(strID));
Assert.IsTrue(img.Exists, "Could not Find: " + strID);
return img;
}
else if (ctrl == Enumerators.ControlType.TableCell)
{
TableCell tCell = ie.TableCell(Find.ById(strID));
Assert.IsTrue(tCell.Exists, "Could not Find: " + strID);
return tCell;
}
else if (ctrl == Enumerators.ControlType.Table)
{
Table tbl = ie.Table(Find.ById(strID));
Assert.IsTrue(tbl.Exists, "Could not Find: " + strID);
return tbl;
}
else if (ctrl == Enumerators.ControlType.TableRow)
{
TableRow row = ie.TableRow(Find.ById(strID));
Assert.IsTrue(row.Exists, "Could not Find: " + strID);
return row;
}
else if (ctrl == Enumerators.ControlType.CheckBox)
{
CheckBox chk = ie.CheckBox(Find.ById(strID));
Assert.IsTrue(chk.Exists, "Could not Find: " + strID);
return chk;
}
else if (ctrl == Enumerators.ControlType.Button)
{
Button btn = ie.Button(Find.ById(strID));
Assert.IsTrue(btn.Exists, "Could not Find: " + strID);
return btn;
}
else if (ctrl == Enumerators.ControlType.TextField)
{
TextField txt = ie.TextField(Find.ById(strID));
Assert.IsTrue(txt.Exists, "Could not Find: " + strID);
return txt;
}
else if (ctrl == Enumerators.ControlType.SelectList)
{
SelectList sList = ie.SelectList(Find.ById(strID));
Assert.IsTrue(sList.Exists, "Could not Find: " + strID);
return sList;
}
else if (ctrl == Enumerators.ControlType.Div)
{
Div division = ie.Div(Find.ById(strID));
Assert.IsTrue(division.Exists, "Could not Find: " + strID);
return division;
}
else if (ctrl == Enumerators.ControlType.TableRow)
{
TableRow tRow = ie.TableRow(Find.ById(strID));
Assert.IsTrue(tRow.Exists, "Could not Find: " + strID);
return tRow;
}
else if (ctrl == Enumerators.ControlType.FileUpload)
{
FileUpload fileUpload = ie.FileUpload(Find.ById(strID));
Assert.IsTrue(fileUpload.Exists, "Could not find: " + strID);
return fileUpload;
}
else
{
return null;
}
}
示例4: Main
static void Main(string[] args)
{
AES aes = new AES();
//grab from the appSettings
string username = AES.Decrypt(ConfigurationManager.AppSettings["username"]);
string password = AES.Decrypt(ConfigurationManager.AppSettings["password"]);
string shoreTelDirectorLogin = AES.Decrypt(ConfigurationManager.AppSettings["ShoreTelDirectorLogin"]);
string shoreTelUserList = AES.Decrypt(ConfigurationManager.AppSettings["ShoreTelUserList"]);
//nav to url
IE myIE = new IE(shoreTelDirectorLogin);
//sign in
myIE.TextField(Find.ByName("login")).TypeText(username);
myIE.TextField(Find.ByName("password")).TypeText(password);
myIE.Button(Find.ByName("SUBMIT1")).Click();
//nav to url containing userList
IE myIE3 = new IE(shoreTelUserList);
//change recPerPage to 3000 to ensure we grab all extensions
myIE3.SelectList(Find.ById("RecPerPage")).Option("3000").Select();
var userListTable = myIE3.Table(Find.By("_t", "Users"));
//create/overwrite javascript file
string jspath = @"C:\SendShoreTelUsersHome.js";
File.Create(jspath).Close();
StreamWriter sw = new StreamWriter(jspath);
//Prepare the ports!
sw.WriteLine("var ports = new ActiveXObject('ShoreBusDS.Ports');");
//writing go home line for each extension
foreach (var tableRow in userListTable.TableRows)
{
//sample text layout of each tr.Text: " Zac Glenn Headquarters Executives Personal 7777 7777 AB77 77 Zac Glenn Home "
if (!string.IsNullOrEmpty(tableRow.Text))
{
Match match = Regex.Match(tableRow.Text, @"\d{4}");
string extension = match.Value;
if (!string.IsNullOrEmpty(extension))
{
sw.WriteLine("ports.UserGoHome('" + extension + "');");
}
}
}
//close file connection because exceptions arise that the file is already in use etc
sw.Close();
//create your cmd process to execute js file using wscript
Process process = new Process();
process.StartInfo.FileName = "wscript.exe";
process.StartInfo.WorkingDirectory = @"c:\";
process.StartInfo.Arguments = "SendShoreTelUsersHome.js";
process.Start();
//close everything we opened
myIE.ForceClose();
}
示例5: FindControlInBrowserByCustom
public static object FindControlInBrowserByCustom(IE ie, string strCustomAttribute, string strToFind,
Enumerators.ControlType ctrl)
{
if (ctrl == Enumerators.ControlType.Span)
{
Span sp = ie.Span(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(sp.Exists, "Could not Find: " + strToFind);
return sp;
}
else if (ctrl == Enumerators.ControlType.Link)
{
Link lnk = ie.Link(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(lnk.Exists, "Could not Find: " + strToFind);
return lnk;
}
else if (ctrl == Enumerators.ControlType.Frame)
{
Frame frame = ie.Frame(Find.By(strCustomAttribute, strToFind));
Assert.AreEqual(frame.Name, strToFind);
return frame;
}
else if (ctrl == Enumerators.ControlType.Image)
{
Image img;
if (strCustomAttribute == "src")
{
img = ie.Image(Find.BySrc(strToFind));
}
else
{
img = ie.Image(Find.By(strCustomAttribute, strToFind));
}
Assert.IsTrue(img.Exists, "Could not Find: " + strToFind);
return img;
}
else if (ctrl == Enumerators.ControlType.TableCell)
{
TableCell tCell = ie.TableCell(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(tCell.Exists, "Could not Find: " + strToFind);
return tCell;
}
else if (ctrl == Enumerators.ControlType.Table)
{
Table tbl = ie.Table(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(tbl.Exists, "Could not Find: " + strToFind);
return tbl;
}
else if (ctrl == Enumerators.ControlType.TableRow)
{
TableRow row = ie.TableRow(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(row.Exists, "Could not Find: " + strToFind);
return row;
}
else if (ctrl == Enumerators.ControlType.CheckBox)
{
CheckBox chk = ie.CheckBox(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(chk.Exists, "Could not Find: " + strToFind);
return chk;
}
else if (ctrl == Enumerators.ControlType.Button)
{
Button btn = ie.Button(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(btn.Exists, "Could not Find: " + strToFind);
return btn;
}
else if (ctrl == Enumerators.ControlType.TextField)
{
TextField txt = ie.TextField(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(txt.Exists, "Could not Find: " + strToFind);
return txt;
}
else if (ctrl == Enumerators.ControlType.SelectList)
{
SelectList sList = ie.SelectList(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(sList.Exists, "Could not Find: " + strToFind);
return sList;
}
else if (ctrl == Enumerators.ControlType.Div)
{
Div div = ie.Div(Find.By(strCustomAttribute, strToFind));
Assert.IsTrue(div.Exists, "Could not Find: " + strToFind);
return div;
}
else
{
return null;
}
}