public void CrossBrowserDemo() { IWebDriver driver; //driver = new ChromeDriver(); //driver = new FirefoxDriver(); // driver = new InternetExplorerDriver(); // driver = new EdgeDriver(); // legacy //https://developer.microsoft.com/en-us/microsoft-edge/tools/webdriver/ for edge //https://docs.microsoft.com/en-us/microsoft-edge/webdriver-chromium // new edge chromium // Make sure you download the chromium msedgedriver.exe from the above link for new chromium edge // for legacy follow the cmd prompt instruction to enble legacy webdriver as mentioned in above link. var options = new Microsoft.Edge.SeleniumTools.EdgeOptions(); options.UseChromium = true; options.BinaryLocation = @"C:\Program Files (x86)\Microsoft\Edge Beta\Application\msedge.exe"; driver = new Microsoft.Edge.SeleniumTools.EdgeDriver(options); driver.Url = "https://abrakh.com/"; driver.Manage().Window.Maximize(); Console.WriteLine(driver.Title); }
private void button2_Click(object sender, EventArgs e) { SoundPlayer SP = new SoundPlayer(@Application.StartupPath + @"\Data\Music\Sou\Nguoi than.wav"); SP.Play(); var driverservice = Microsoft.Edge.SeleniumTools.EdgeDriverService.CreateChromiumService(); driverservice.HideCommandPromptWindow = true; var options = new Microsoft.Edge.SeleniumTools.EdgeOptions(); options.UseChromium = true; options.BinaryLocation = @"C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe"; var driver = new Microsoft.Edge.SeleniumTools.EdgeDriver(driverservice, options); driver.Url = "https://www.messenger.com/login/"; driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5); IWebElement query = driver.FindElement(By.CssSelector("#email")); query.SendKeys("ldh2210"); query = driver.FindElement(By.CssSelector("#pass")); query.SendKeys("lehoang2210kt"); query = driver.FindElement(By.CssSelector("#loginbutton")); query.Click(); driver.Navigate().GoToUrl("https://www.messenger.com/t/100012544930422"); query = driver.FindElement(By.XPath(".//*[@role = 'presentation']")); query.Click(); //driver.Quit(); }
static void downloadReport() { Console.WriteLine("Downloading Report ..."); String url = "https://www.who.int/healthinfo/statistics/data/en/"; //Setup EdgeOptions edgeOptions = new Microsoft.Edge.SeleniumTools.EdgeOptions(); edgeOptions.UseChromium = true; //edgeOptions.AddUserProfilePreference() //edgeOptions.AddArgument("headless"); IWebDriver _driver = new Microsoft.Edge.SeleniumTools.EdgeDriver("./files/drivers", edgeOptions); //Open Browser _driver.Url = url; Console.WriteLine(_driver.Title); //Download Excel IReadOnlyList <IWebElement> listExcel = _driver.FindElement(By.Id("primary")).FindElements(By.TagName("A")); Console.WriteLine(listExcel.Count.ToString()); //Extract Data from Excel and Store in DB foreach (IWebElement item in listExcel) { Console.WriteLine(item.Text); item.Click(); System.Threading.Thread.Sleep(4000); //Wait for the alert to be displayed and store it in a variable //Alert alert = wait.until(ExpectedConditions.alertIsPresent()); //Type your message //alert.sendKeys("Selenium"); //Press the OK button //alert.dismiss(); break; } //Tear Down _driver?.Quit(); _driver?.Dispose(); }