Chrome.ChromeDriver wbb; // = new Chrome.ChromeDriver(); private void getFileList_Cloud() { Thread.Sleep(200); var frame = wbb.FindElementByName("mainframe"); var link = frame.GetAttribute("src"); //wbb.Url = getHost(wbb.Url) + "/" + link; wbb.Url = link; Thread.Sleep(200); var foldListElem = wbb.FindElementById("sub_folder_list"); var foldNameElems = foldListElem.FindElements(By.ClassName("f_name2")); var foldNames = foldNameElems.Select(x => x.Text); ///var fileElems1 = wbb.FindElementById("filelist"); var fileElems = wbb.FindElements(By.XPath("//div[@id='filelist']/div[@class='f_tb']")); var fileInfos = new List <FileInfo>(); foreach (var x in fileElems) { FileInfo inf = new FileInfo(); inf.name = x.FindElement(By.XPath("./div[@class='f_name']/a")).Text; inf.size = x.FindElement(By.CssSelector("div.f_size")).Text; fileInfos.Add(inf); } //this.Title = fileInfos.First().name; }
public ActionResult Index() { var driver = new ChromeDriver(); //driver.Navigate().GoToUrl("http://diesel.elcat.kg"); driver.Navigate().GoToUrl("http://diesel.elcat.kg/index.php?act=Login"); // Get the page elements var userNameField = driver.FindElementByName("UserName"); var userPasswordField = driver.FindElementByName("PassWord"); var loginButton = driver.FindElementByXPath("//input[@name='submit']"); // Type user name and password userNameField.SendKeys("bishkek312"); userPasswordField.SendKeys("8061"); // and click the login button loginButton.Click(); driver.Navigate().GoToUrl("http://diesel.elcat.kg/index.php?showtopic=43884872"); DeleteLastUp(driver); var messageField = driver.FindElementById("fast-reply_textarea"); messageField.SendKeys(upMessageValue); var sendButton = driver.FindElementByXPath("//input[@value='Отправить']"); return new EmptyResult(); //return View(); }
public static void Register(BackgroundWorker worker, string name, string password, IList<string> barcodes) { driver = new ChromeDriver(); driver.Navigate().GoToUrl("https://7777.bg/user/lottery_tickets/register/"); driver.FindElementByName("login_username").SendKeys(name); driver.FindElementByName("login_password").SendKeys(password); driver.FindElementByXPath("//input[@type='submit']").Click(); Wait(driver); var barcodeTextBox = driver.FindElementByName("register_number"); var submitButton = driver.FindElementByXPath("//button[@type='submit']"); int progressPercentage = Convert.ToInt32(100 / barcodes.Count); for (int i = 0; i < barcodes.Count; i++) { barcodeTextBox.SendKeys(barcodes[i]); submitButton.Click(); Thread.Sleep(1000); var finishButton = driver.FindElementByXPath("//a[@href='javascript:void(0);']"); finishButton.Click(); worker.ReportProgress(progressPercentage * (i + 1)); Thread.Sleep(1000); } }
static void Main(string[] args) { var driver = new ChromeDriver(); // Should work in other Browser Drivers string baseLink = "http://www.codeproject.com"; //foreach (var link in links) for (int i = 2326; i > 2325; i--) { string link = baseLink + i.ToString(); driver.Navigate().GoToUrl(link); try { var login = driver.FindElementById("Button1"); var uName = driver.FindElementByName("lname"); var pass = driver.FindElementByName("passw"); uName.SendKeys("admin"); pass.SendKeys("*******"); login.Submit(); } catch { //already logged in } Screenshot ss = ((ITakesScreenshot)driver).GetScreenshot(); //Use it as you want now string screenshot = ss.AsBase64EncodedString; byte[] screenshotAsByteArray = ss.AsByteArray; FileNameFromURL fileNameFromURL = new ConsoleApplication1.FileNameFromURL(); string filePath = Application.StartupPath + fileNameFromURL.ConvertToWindowsFileName(link) + ".jpg"; if (File.Exists(filePath)) { File.Delete(filePath); } ss.SaveAsFile(filePath, ImageFormat.Png); //use any of the built in image formating ss.ToString();//same as string screenshot = ss.AsBase64EncodedString; } //driver.Dispose(); driver.Close(); }
static void Main(string[] args) { //Declaration //l = phone numbers, quotation number, desc of the records, entity, submission date , submission time, name of user List<string> l = new List<string>(); List<string> quotation = new List<string>(); List<string> desc = new List<string>(); List<string> entity = new List<string>(); List<string> subDate = new List<string>(); List<string> subTime = new List<string>(); List<string> name = new List<string>(); List<string> kw = new List<string>(); Dictionary<string, string> dict = new Dictionary<string, string>(); int numbrecords = 0; string filename = ""; #region Load google chrome // Initialize the Chrome Driver using (var driver = new ChromeDriver()) { LoadFile(ref l, ref dict); // Go to the home page driver.Navigate().GoToUrl("http://www.gebiz.gov.sg/scripts/main.do?sourceLocation=openarea&select=tenderId"); #region autofill and extract data from GeBiz webpage foreach (var val in l) { //Get the page elements var fromdate = driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[2]/tbody/tr/td/table/tbody/tr[2]/td/table/tbody/tr[5]/td[4]/input"); var todate = driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[2]/tbody/tr/td/table/tbody/tr[2]/td/table/tbody/tr[5]/td[6]/input"); var keyword = driver.FindElementByName("searchByDesc"); new SelectElement(driver.FindElement(By.Name("dateType"))).SelectByIndex(1); var submitbutton = driver.FindElementByName("submitAction"); fromdate.SendKeys(DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy")); todate.SendKeys(DateTime.Now.AddDays(-1).ToString("dd/MM/yyyy")); keyword.SendKeys(val); //click the submit button submitbutton.Click(); if (driver.FindElements(By.XPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[2]/td")).Count == 1) { driver.Navigate().GoToUrl("http://www.gebiz.gov.sg/scripts/main.do?sourceLocation=openarea&select=tenderId"); } else { if (driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[2]/td").Text.Equals("No data found")) { Console.WriteLine("No Data Found"); driver.Navigate().GoToUrl("http://www.gebiz.gov.sg/scripts/main.do?sourceLocation=openarea&select=tenderId"); } else { #region Checking the number of records for (int j = 11; j > 1; j--) { //select the records by row if (driver.FindElements(By.XPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[" + j + "]")).Count == 1) { Console.WriteLine(driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[2]/td").Text); numbrecords = j + 1; #region Storing quotation and desc to list for (int i = 2; i < numbrecords; i++) { //get the record from the current row on the quotation col quotation.Add(driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[" + i + "]/td[2]/table/tbody/tr[1]/td/a/b").Text); //get the record from the current row on the description col desc.Add(driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[" + i + "]/td[3]/table/tbody/tr[1]/td").Text); //get the record from the current row on entity from description col entity.Add(RemoveWord(driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[" + i + "]/td[3]/table/tbody/tr[2]/td").Text)); //get the record from the current row on submission date from closing date/time col subDate.Add(driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[" + i + "]/td[5]/table/tbody/tr[1]/td").Text); //get the record from the current row on submission time from closing date/time col subTime.Add(driver.FindElementByXPath("/html/body/table/tbody/tr[2]/td[2]/table/tbody/tr[2]/td/form/table[3]/tbody/tr/td/table[1]/tbody/tr[" + i + "]/td[5]/table/tbody/tr[2]/td").Text); //add the name of the organisation that the keyword belong to name.Add(dict[val]); //add the keyword kw.Add(val); } driver.Navigate().GoToUrl("http://www.gebiz.gov.sg/scripts/main.do?sourceLocation=openarea&select=tenderId"); break; #endregion } } #endregion } } } #endregion } #endregion //saving to excel file filename = SaveExcel(); ExportData(filename, ref quotation, ref desc, ref entity, ref subDate, ref subTime, ref name, ref kw); }
public CommunicationsResponse RetrieveSelectedBankAccountDetails(BankCommsCapsule capsule) { string address = "https://online.mbank.pl/pl/Login"; CommunicationsResponse response = new CommunicationsResponse(); ChromeDriver driver = new ChromeDriver(); driver.Navigate().GoToUrl(address); // WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10)); Thread.Sleep(3000); IWebElement login = driver.FindElementByName("userID"); IWebElement password = driver.FindElementByName("pass"); login.SendKeys(capsule._login); password.SendKeys(capsule._password); password.Submit(); driver.Navigate().GoToUrl("https://online.mbank.pl/pl#/accounts"); Thread.Sleep(3000); // IWebElement account = driver.FindElementByName driver.Quit(); return response; }
public void ButtonByName(string path, ChromeDriver driver) { var button = driver.FindElementByName(path); driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 30)); button.Click(); }