Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
hacktonxx
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Xml.Linq; using System.Data; using System.Web.Services; using System.Runtime.Serialization.Json; using System.IO; using System.Text; namespace TestAutomation { public partial class TestAutomation : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { DataTable dt = new DataTable(); dt.Columns.Add("ID", typeof(string)); DataRow dr = dt.NewRow(); DataRow dr1 = dt.NewRow(); dr["ID"] = ""; dr1["ID"] = ""; dt.Rows.Add(dr); dt.Rows.Add(dr1); GridView1.DataSource = dt; GridView1.DataBind(); } } protected static string submit(Thing[] things,string targtool) { XDocument xfile = XDocument.Load(@"c:\users\administrator\documents\visual studio 2015\Projects\TestAutomation\TestAutomation\Data\Repo1.xml"); XDocument xfilet = XDocument.Load(@"c:\users\administrator\documents\visual studio 2015\Projects\TestAutomation\TestAutomation\Data\Repo2.xml"); XDocument xfilemeta = null; string CompleteScript=string.Empty; if (targtool == "UFT(VBScript)") xfilemeta = XDocument.Load(@"c:\users\administrator\documents\visual studio 2015\Projects\TestAutomation\TestAutomation\Data\UFT.xml"); else if (targtool == "Selenium(Java)") xfilemeta = XDocument.Load(@"c:\users\administrator\documents\visual studio 2015\Projects\TestAutomation\TestAutomation\Data\Selenium.xml"); foreach (Thing thing in things) { string objectname = thing.ID; string testdata = thing.TestDate; string operation = thing.Operation; var item = from x in xfile.Descendants("Elements").Descendants("Element") where ((string)x.Element("name")).ToLower() == objectname.ToLower() select x; var btitle = from x in xfilet.Descendants("Settings").Descendants("Browser") select x; var ptitle = from x in xfilet.Descendants("Settings").Descendants("Page") select x; // == p1 select x; //var name = from nm in xfile.Elements("Element") // where (string)nm.Element("name") == "username" // select nm; //XElement xelement = XElement.Load("..\\..\\Employees.xml"); //IEnumerable<XElement> employees = xelement.Elements(); //Console.WriteLine("List of all Employee Names :"); //foreach (var employee in employees) //{ // Console.WriteLine(employee.Element("Name").Value); //} string cmd = "Invalid Objects"; if (item.Any()) { string xpath = item.SingleOrDefault().Element("xpath").Value; string brtitle = btitle.SingleOrDefault().Element("title").Value; string patitle = ptitle.SingleOrDefault().Element("title").Value; string type = item.SingleOrDefault().Element("type").Value; string objpart = xpath.Split('\'')[1]; var eventstmt = from x in xfilemeta.Descendants("Elements").Descendants("Element") where (string)x.Element("type") == type && (string)x.Element("operation") == operation select x; cmd = "Invalid Criteria"; string UFTstatement = "Set obj = Browser(\"name:= {0}\").Page(\"title:= {1}\").Object.getElementsByName(\"{2}\")<br/>"; string seleniumstmt = "driver.findElement(By.xpath(\"{0}\"))."; string operationcmd = ""; if (eventstmt.Any()) { operationcmd = string.Format(eventstmt.SingleOrDefault().Element("cmd").Value, testdata); switch (targtool) { case "UFT(VBScript)": cmd = string.Format(UFTstatement, brtitle, patitle, objpart) + operationcmd; // statement += "<br/>" + eventstmt.SingleOrDefault().Element("cmd").Value + testdata+"\""; break; case "Selenium(Java)": cmd = string.Format(seleniumstmt, xpath) + operationcmd; // statement += "<br/>" + eventstmt.SingleOrDefault().Element("cmd").Value; break; //case "": break; default: break; } } } cmd += "<br/>"; CompleteScript += cmd; // } return CompleteScript; // lblCmd.Text = cmd; } private static string SerializeObjectIntoJson(string p) { DataContractJsonSerializer serializer = new DataContractJsonSerializer(p.GetType()); using (MemoryStream ms = new MemoryStream()) { serializer.WriteObject(ms, p); ms.Flush(); byte[] bytes = ms.GetBuffer(); string jsonString = Encoding.UTF8.GetString(bytes, 0, bytes.Length).Trim('\0'); return jsonString; } } [WebMethod] public static string GetCityNameArray(Thing[] things) { return SerializeObjectIntoJson(submit(things, things[0].Engine.ToString())); } protected void btnsubmit_Click(object sender, EventArgs e) { var results = GridView1.Rows.Count; //submit(txtobj.Value,txttestdata.Value); } public class Thing { public string ID { get; set; } public string Operation { get; set; } public string TestDate { get; set; } public string Engine { get; set; } } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { } } }
run
|
edit
|
history
|
help
0
наименьшее общее кратное двух чисел a и b
SELECT YEAR('2019-08-15 01:02:03')+10
Swap numbers without the third variable using the XOR operator
Need to convert datetime containg '/' to '-' format
HuyLe
Z_non_pow
Test
Simple Selection Sort
araray
DN2