public void TestHappyPathChrome() { ChromeOptions co = new ChromeOptions(); co.AddArgument("--test-type"); ChromeDriver cd = new ChromeDriver("C:\\Users\\ehelin\\Downloads\\chromedriver_win32", co); TestHappyPath(cd); }
public virtual void InitializeDriver() { InitializeSettings(); switch (BrowserType) { case BrowserType.Chrome: var chromeOptions = new ChromeOptions(); chromeOptions.AddArguments(new string[] { "--no-sandbox", "test-type", "--start-maximized" }); var chromeDriverService = ChromeDriverService.CreateDefaultService(); chromeDriverService.HideCommandPromptWindow = false; Context.Driver = new ChromeDriver(chromeDriverService, chromeOptions, TimeSpan.FromSeconds(300.0)); break; case BrowserType.Firefox: var capabilities = new DesiredCapabilities(); capabilities.SetCapability(CapabilityType.UnexpectedAlertBehavior, "dismiss"); Context.Driver = new FirefoxDriver(capabilities); break; } Context.Browser = new Browser(); Context.Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(Context.Settings.WaitTimeout)); Context.Driver.Navigate().GoToUrl("about:blank"); Context.Driver.SwitchTo().Window(Context.Driver.WindowHandles.First()); }
public void Login(String loginUrl) { var options = new ChromeOptions(); options.AddArguments("--test-type", "--start-maximized"); options.AddArguments("--test-type", "--ignore-certificate-errors"); options.BinaryLocation = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"; driver = new ChromeDriver("C:\\Program Files (x86)\\Google\\Chrome\\Application", options); driver.Navigate().GoToUrl(loginUrl); int timeout = 0; while (driver.FindElements(By.ClassName("logbox")).Count == 0 && timeout < 500) { Thread.Sleep(1); timeout++; } IWebElement element = driver.FindElement(By.ClassName("logbox")); IWebElement ElName = element.FindElement(By.Name("username")); ElName.Clear(); ElName.SendKeys(loginName); IWebElement ElPassword = element.FindElement(By.Id("password")); ElPassword.Clear(); ElPassword.SendKeys(loginPassword); IWebElement ElLogin = element.FindElement(By.Id("IBtnLogin")); ElLogin.Click(); }
private static ChromeOptions GetChromeOptions() { var option = new ChromeOptions(); option.AddArgument("start-maximized"); option.AddExtension(@"C:\downloads\GoogleAnalytics.crx"); option.Proxy = null; return option; }
/// <summary> /// Creates the web driver. /// </summary> /// <param name="browserType">Type of the browser.</param> /// <param name="browserFactoryConfiguration">The browser factory configuration.</param> /// <returns>The created web driver.</returns> /// <exception cref="System.InvalidOperationException">Thrown if the browser is not supported.</exception> internal static IWebDriver CreateWebDriver(BrowserType browserType, BrowserFactoryConfigurationElement browserFactoryConfiguration) { IWebDriver driver; if (!RemoteDriverExists(browserFactoryConfiguration.Settings, browserType, out driver)) { switch (browserType) { case BrowserType.IE: var explorerOptions = new InternetExplorerOptions { EnsureCleanSession = browserFactoryConfiguration.EnsureCleanSession }; var internetExplorerDriverService = InternetExplorerDriverService.CreateDefaultService(); internetExplorerDriverService.HideCommandPromptWindow = true; driver = new InternetExplorerDriver(internetExplorerDriverService, explorerOptions); break; case BrowserType.FireFox: driver = GetFireFoxDriver(browserFactoryConfiguration); break; case BrowserType.Chrome: var chromeOptions = new ChromeOptions { LeaveBrowserRunning = false }; var chromeDriverService = ChromeDriverService.CreateDefaultService(); chromeDriverService.HideCommandPromptWindow = true; driver = new ChromeDriver(chromeDriverService, chromeOptions); break; case BrowserType.PhantomJS: var phantomJsDriverService = PhantomJSDriverService.CreateDefaultService(); phantomJsDriverService.HideCommandPromptWindow = true; driver = new PhantomJSDriver(phantomJsDriverService); break; case BrowserType.Safari: driver = new SafariDriver(); break; default: throw new InvalidOperationException(string.Format("Browser type '{0}' is not supported in Selenium local mode. Did you mean to configure a remote driver?", browserType)); } } // Set Driver Settings var managementSettings = driver.Manage(); // Set timeouts var applicationConfiguration = SpecBind.Helpers.SettingHelper.GetConfigurationSection().Application; managementSettings.Timeouts() .ImplicitlyWait(browserFactoryConfiguration.ElementLocateTimeout) .SetPageLoadTimeout(browserFactoryConfiguration.PageLoadTimeout); ActionBase.DefaultTimeout = browserFactoryConfiguration.ElementLocateTimeout; WaitForPageAction.DefaultTimeout = browserFactoryConfiguration.PageLoadTimeout; ActionBase.RetryValidationUntilTimeout = applicationConfiguration.RetryValidationUntilTimeout; // Maximize window managementSettings.Window.Maximize(); return driver; }
public static IWebDriver StartDriver (string browserType) { Trace.WriteLine("Start browser: '" + browserType + "'"); IWebDriver driver = null; switch (browserType) { case "ie": { driver = new InternetExplorerDriver("Drivers"); break; } case "firefox": { FirefoxProfile firefoxProfile = new FirefoxProfile(); firefoxProfile.EnableNativeEvents = true; firefoxProfile.AcceptUntrustedCertificates = true; driver = new FirefoxDriver(firefoxProfile); break; } case "chrome": { ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.AddArgument("--disable-keep-alive"); driver = new ChromeDriver("Drivers", chromeOptions); break; } } driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3)); driver.Manage().Window.Maximize(); return driver; }
public void Start() { var options = new ChromeOptions(); options.AddArgument("--test-type"); Instance = new RemoteWebDriver(ChromeDriver.BaseUrl, options.ToCapabilities()); }
public Host() { // Hack int retryCount = 3; while (true) { try { var options = new ChromeOptions(); options.AddArguments("test-type"); var service = ChromeDriverService.CreateDefaultService(@"..\..\Scaffolding\WebDriver"); service.HideCommandPromptWindow = false; WebDriver = new ChromeDriver(service, options); WebDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5)); Page = new Page(WebDriver); Page.GotoUrl("Home"); break; } catch { if (retryCount-- == 0) throw; } } }
private static void InitializeWebDriver() { switch (Configuration.BrowserType) { case BrowserType.Firefox: WebDriver = new FirefoxDriver(); break; case BrowserType.InternetExplorer: var ieOptions = new InternetExplorerOptions { EnableNativeEvents = true, EnablePersistentHover = true, EnsureCleanSession = true, UnexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Dismiss }; WebDriver = new InternetExplorerDriver("./", ieOptions); break; case BrowserType.Chrome: var chromeOptions = new ChromeOptions(); chromeOptions.AddArguments("test-type"); WebDriver = new ChromeDriver("./", chromeOptions); break; default: throw new ArgumentException("Unknown browser type is specified!"); } WebDriver.Manage().Window.Maximize(); WebDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromMilliseconds(Configuration.ImplicitWaitTime)); }
public void GetsHeader() { var options = new OpenQA.Selenium.Chrome.ChromeOptions(); options.AddArguments("--headless", "--disable-gpu", "windows-size=1280x1696", "--no-sandbox", "--user-data-dir=/tmp/user-data", "--hide-scrollbars", "--enable-logging", "--log-level=0", "--v=99", "--single-process", "--data-path=/tmp/data-path", "--ignore-certificate-errors", "--homedir=/tmp", "--disk-cache-dir=/tmp/cache-dir"); options.BinaryLocation = "/var/task/chrome"; var webdriver = new ChromeDriver(options); webdriver.Url = "http://www.google.com"; string Title = webdriver.Title; LambdaLogger.Log($"Running test: Title for page {webdriver.Url} is: {Title}\n"); webdriver.Quit(); Assert.Equal("Google", Title); }
private IWebDriver get_local_chrome_driver() { var options = new OpenQA.Selenium.Chrome.ChromeOptions(); //options.BinaryLocation = "/usr/share/iron/chrome-wrapper"; options.BinaryLocation = "/usr/share/iron/chrome"; options.AddArgument("--disable-extensions"); // options.BinaryLocation = "/wd/hub"; options.DebuggerAddress = Debugger_Host_And_Port; //new ChromeDriver(chrome_driver_binary, chrome_options=options); return(new ChromeDriver(BinaryLocation, options)); //return new ChromeDriver("/media/jhaines/tera27/file-set/workspace/CoffeeBreak/src/test/bin/Debug/netcoreapp2.1/"); /* * System.setProperty("webdriver.chrome.driver",""); * * * using (var driver = new ChromeDriver("/media/jhaines/tera27/file-set/workspace/coffeebreak-test/bin/Debug/netcoreapp2.1/", options)) * */ // Initialize the Chrome Driver //using (var driver = new ChromeDriver("/media/jhaines/tera27/file-set/workspace/coffeebreak-test/bin/Debug/netcoreapp2.1/", options)) }
public static IWebDriver GetDriver(DriverType typeOfDriver) { IWebDriver browser; switch (typeOfDriver) { // NOTE REMOTE DRIVER IS NOT SUPPORTED case DriverType.Chrome: ChromeOptions co = new ChromeOptions(); browser = new ChromeDriver(); break; case DriverType.IE: InternetExplorerOptions ieo = new InternetExplorerOptions(); browser = new InternetExplorerDriver(); break; case DriverType.Firefox: default: FirefoxProfile ffp = new FirefoxProfile(); ffp.AcceptUntrustedCertificates = true; ffp.Port = 8181; browser = new FirefoxDriver(ffp); break; } return browser; }
private static ChromeOptions GetChromeOptions() { ChromeOptions option = new ChromeOptions(); option.AddArgument("start-maximized"); option.Proxy = null; return option; }
public static IWebDriver CreateDriver() { ChromeOptions options = new ChromeOptions(); options.AddArgument("--disable-cache"); var driver = new ChromeDriver(options); return driver; }
internal void Launch(bool mobile, string url = "https://www.bing.com/") { Quit(); _viewModel.ResetProfileCommand.RaiseCanExecuteChanged(); ChromeDriverService service = ChromeDriverService.CreateDefaultService(App.Folder); service.HideCommandPromptWindow = true; ChromeOptions options = new ChromeOptions(); options.AddArgument("start-maximized"); options.AddArgument("user-data-dir=" + App.Folder + "profile"); if (mobile) options.EnableMobileEmulation("Google Nexus 5"); try { _driver = new ChromeDriver(service, options); _driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(3)); _builder = new Actions(_driver); LogUpdate("Launching Chrome " + (mobile ? "Mobile" : "Desktop"), Colors.CadetBlue); if (url != null) _driver.Navigate().GoToUrl(url); } catch (Exception ex) { LogUpdate("Error Launching Chrome " + (mobile ? "Mobile" : "Desktop") + "\r\n" + ex.Message, Colors.Red); service.Dispose(); } }
public InboxModel(string username, string password, BackgroundWorker bw, bool tv) { ChromeDriverService service = ChromeDriverService.CreateDefaultService(App.Folder); service.HideCommandPromptWindow = true; ChromeOptions options = new ChromeOptions(); options.AddArgument("start-maximized"); options.AddArgument("user-data-dir=" + App.Folder + "profileIB"); IWebDriver driver = new ChromeDriver(service, options); driver.Navigate().GoToUrl("http://www.inboxdollars.com"); try { driver.FindElement(By.Id("loginname")).Clear(); driver.FindElement(By.Id("pwd")).Clear(); driver.FindElement(By.Id("loginname")).SendKeys(username); driver.FindElement(By.Id("pwd")).SendKeys(password); Helpers.wait(1000); driver.FindElement(By.ClassName("submit2")).Click(); } catch { } try { if (driver.FindElement(By.Id("emailsBlock")).FindElement(By.ClassName("textBox")).Text != "0") { driver.FindElement(By.Id("emailsBlock")).FindElement(By.ClassName("textBox")).Click(); } } catch { } if (!tv) { try { driver.FindElement(By.ClassName("videos")).Click(); videos(driver); } catch { } } else if (tv) { try { driver.FindElement(By.ClassName("tv")).Click(); Helpers.wait(2000); Helpers.ByClass(driver, "jw-icon"); while (true) { try { driver.FindElement(By.Id("tvStillTherePopupContinue")).Click(); } catch { } } } catch { } } }
/// <summary> /// Get a RemoteWebDriver /// </summary> /// <param name="browser">the Browser to test on</param> /// <param name="languageCode">The language that the browser should accept.</param> /// <returns>a IWebDriver</returns> IWebDriver IWebDriverFactory.GetWebDriver(Browser browser, string languageCode) { //What browser to test on?s IWebDriver webDriver; switch (browser.Browserstring.ToLowerInvariant()) { case "firefox": var firefoxProfile = new FirefoxProfile(); firefoxProfile.SetPreference("intl.accept_languages", languageCode); webDriver = new FirefoxDriver(firefoxProfile); break; case "chrome": ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.AddArguments("--test-type", "--disable-hang-monitor", "--new-window", "--no-sandbox", "--lang=" + languageCode); webDriver = new ChromeDriver(chromeOptions); break; case "internet explorer": webDriver = new InternetExplorerDriver(new InternetExplorerOptions { BrowserCommandLineArguments = "singleWindow=true", IntroduceInstabilityByIgnoringProtectedModeSettings = true, EnsureCleanSession = true, EnablePersistentHover = false }); break; case "phantomjs": webDriver = new PhantomJSDriver(new PhantomJSOptions() {}); break; default: throw new NotSupportedException("Not supported browser"); } return webDriver; }
public API_Chrome_Hijack() { ChromeDriverDownloadLink = @"http://chromedriver.googlecode.com/files/chromedriver_win_26.0.1383.0.zip"; WebDriver_Folder = @"Selenium\net40\WebDriver.dll".assembly().location().parentFolder(); ChromeDriver_Exe = WebDriver_Folder.pathCombine("chromedriver.exe"); ChromeOptions = new ChromeOptions(); ChromeDriverService = ChromeDriverService.CreateDefaultService(); }
/// <summary> /// Creates an ChromeDriver instance using the specified proxy settings. /// </summary> /// <param name="proxy">The WebDriver Proxy object containing the proxy settings.</param> /// <returns>An ChromeDriver instance using the specified proxy settings</returns> private static IWebDriver CreateChromeDriverWithProxy(Proxy proxy) { ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.Proxy = proxy; IWebDriver driver = new ChromeDriver(chromeOptions); return driver; }
private static ChromeOptions GetChromeOptions() { ChromeOptions option = new ChromeOptions(); option.AddArgument("start-maximized"); // option.AddExtension(@"C:\Users\rahul.rathore\Desktop\Cucumber\extension_3_0_12.crx"); return option; }
//private const int volumizingCounter = 100; public ChatGeneratorClass() { ChromeOptions options = new ChromeOptions(); options.AddArguments("--incognito"); options.AddArguments("--start-minimized"); driver = new ChromeDriver(options); baseUrl = "http://pofig.livetex.ru/"; }
public ChromeFactory() { var option = new OSC.ChromeOptions(); _cookieContainer = new CookieContainer(); _driver = new OSC.ChromeDriver(GetChromeDriverService(), option); }
/// <summary> /// Returns an initialised Chrome Web Driver. /// </summary> /// <remarks>You need to have chromedriver.exe embedded into your assembly and have Chrome installed on the machine running the test</remarks> /// <returns>Initialised Chrome driver</returns> public static ChromeDriver Chrome() { var options = new ChromeOptions(); // addresses issue: https://code.google.com/p/chromedriver/issues/detail?id=799 options.AddArgument("test-type"); return new WebDriverBuilder<ChromeDriver>(() => new ChromeDriver(options)) .WithFileName("chromedriver.exe"); }
private static IWebDriver GetChromeBrowser() { var service = ChromeDriverService.CreateDefaultService(Path.GetFullPath(Constants.DriversDirectory)); var options = new ChromeOptions(); options.AddUserProfilePreference("download.default_directory", Path.GetFullPath(Constants.WallpapersDirectory)); var browser = new ChromeDriver(service, options); return browser; }
public static void CreateWebDriver() { ChromeOptions options = new ChromeOptions(); options.AddArgument("--start-maximized"); driver = new ChromeDriver("../../Drivers", options, TimeSpan.FromSeconds(Timeout)); driver.Manage().Timeouts().SetScriptTimeout(TimeSpan.FromSeconds(Timeout)); driver.Manage().Cookies.DeleteAllCookies(); driver.Url = URL; }
public void GetChromeBrowserWithOptions() { var options = new ChromeOptions(); options.AddArgument("-incognito"); Assume.That(_driver.GetNuGetChromeDriver()); _driver = WebDriverFactory.GetBrowser<ChromeDriver, ChromeOptions>(options, "http://rickcasady.blogspot.com/"); }
private static IWebDriver GetLocalWebDriver() { var chromeDriverPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..", Configuration.Instance.Selenium.ChromeDriverPath); var options = new ChromeOptions(); return new ChromeDriver(chromeDriverPath, options); }
public tstObject(int typNum) { brwsrType = typNum; switch (typNum) { //create a Chrome object case 1: { var options = new ChromeOptions(); //set the startup options to start maximzed options.AddArguments("start-maximized"); //start Chrome maximized driver = new ChromeDriver(@Application.StartupPath, options); //Wait 10 seconds for an item to appear driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(4)); break; } //create an IE object case 2: { //var options = new InternetExplorerOptions(); //set the startup options to start maximzed //options.ToCapabilities(); driver = new InternetExplorerDriver(@Application.StartupPath); //maximize window driver.Manage().Window.Maximize(); //Wait 4 seconds for an item to appear driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(4)); break; } default: { FirefoxProfile profile = new FirefoxProfile(); profile.SetPreference("webdriver.firefox.profile", "cbufsusm.default"); profile.AcceptUntrustedCertificates = true; driver = new FirefoxDriver(profile); //profile //maximize window driver.Manage().Window.Maximize(); //Wait 4 seconds for an item to appear driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(4)); break; } } }
public static void BeforeTestRun() { ChromeOptions optionChrome = new ChromeOptions(); optionChrome.AddAdditionalCapability("chrome.noWebsiteTestingDefaults", false); optionChrome.AddAdditionalCapability("chrome.applicationCacheEnabled", false); Driver = new ChromeDriver(); Driver.Manage().Cookies.DeleteAllCookies(); Driver.Manage().Window.Maximize(); Driver.Manage().Timeouts().ImplicitlyWait(new TimeSpan(0, 0, 5)); }
private ChromeDriver LaunchChrome() { // Disable the remember password popups, and make sure it's full screen so that Bootstrap elements aren't hidden ChromeOptions options = new ChromeOptions(); options.AddArgument("--incognito"); options.AddArgument("--start-maximized"); ChromeDriver chromeDriver = new ChromeDriver(options); chromeDriver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(2)); return chromeDriver; }
public API_Chrome_Hijack() { ChromeDriverDownloadLink = @"http://chromedriver.storage.googleapis.com/2.21/chromedriver_win32.zip"; WebDriver_Folder = @"Selenium\net40\WebDriver.dll".assembly().location().parentFolder(); ChromeDriver_Exe = WebDriver_Folder.pathCombine("chromedriver.exe"); ChromeOptions = new ChromeOptions(); ensureChromeDriverExists(); ChromeDriverService = ChromeDriverService.CreateDefaultService(); }
private ChromeDriver CreateChromeDriver() { var options = new ChromeOptions(); var exePath = Settings.ChromeExecutablePath; if (!string.IsNullOrEmpty(exePath) && File.Exists(exePath)) options.BinaryLocation = exePath; return new ChromeDriver(options); }
public static void Follow() { var options = new OpenQA.Selenium.Chrome.ChromeOptions(); options.BinaryLocation = @"C:\Program Files\Google\Chrome\Application\chrome.exe"; using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(options)) { var bilgi = Login(driver); var follwers = Takipçiler(bilgi, driver); NameFollow(follwers, driver); } }
private static IWebDriver CreateChromeDriver(string driversDirectory, bool silentMode, List <object> chromeSwitches = null, Dictionary <string, bool> chromeProfiles = null, int chromePort = 0, bool chromeAttach = false) { var chromeService = Chrome.ChromeDriverService.CreateDefaultService(driversDirectory); chromeService.HideCommandPromptWindow = true; var chromeOptions = new Chrome.ChromeOptions { PageLoadStrategy = PageLoadStrategy.None }; SetupChromiumOptions(chromeOptions, silentMode, chromeSwitches, chromeProfiles, chromePort, chromeAttach); return(new Chrome.ChromeDriver(chromeService, chromeOptions)); }
private static IWebDriver CreateChromeDriver(string driversDirectory, bool silentMode) { var chromeService = Chrome.ChromeDriverService.CreateDefaultService(driversDirectory); chromeService.HideCommandPromptWindow = true; var chromeOptions = new Chrome.ChromeOptions { PageLoadStrategy = PageLoadStrategy.None }; SetupChromiumOptions(chromeOptions, silentMode); return(new Chrome.ChromeDriver(chromeService, chromeOptions)); }
public WebHelper() { OpenQA.Selenium.Chrome.ChromeDriverService service = OpenQA.Selenium.Chrome.ChromeDriverService.CreateDefaultService(); OpenQA.Selenium.Chrome.ChromeOptions chromeOptions = new OpenQA.Selenium.Chrome.ChromeOptions(); driver = new ChromeDriver(service, chromeOptions, TimeSpan.FromSeconds(180)); baseURL = "https://scryptmail.com/"; rnd = new Random(); waitPeriod = 30.0; logs = ""; pathLogs = System.IO.Directory.GetCurrentDirectory() + @"\logs.txt"; pathLP = System.IO.Directory.GetCurrentDirectory() + @"\lp.txt"; checkLogsFile(); checkLPFile(); }
private void CreateDriverIfNeeded() { if (null != _driver) { return; } var options = new OpenQA.Selenium.Chrome.ChromeOptions(); options.AddArguments(new List <string>() { "headless", "no-sandbox", "disable-dev-shm-usage" }); var workingDir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); ChromeDriverService service = ChromeDriverService.CreateDefaultService(workingDir); service.Port = 40785; _driver = new OpenQA.Selenium.Chrome.ChromeDriver(service, options); }
public static void EtiketTakip() { var options = new OpenQA.Selenium.Chrome.ChromeOptions(); options.BinaryLocation = @"C:\Program Files\Google\Chrome\Application\chrome.exe"; using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(options)) { driver.Navigate().GoToUrl("https://www.instagram.com"); Thread.Sleep(2000); IWebElement userName = driver.FindElement(By.Name("username")); IWebElement password = driver.FindElement(By.Name("password")); IWebElement girisbutonu = driver.FindElement(By.CssSelector(".sqdOP.L3NKy.y3zKF")); Bilgiler bilgi = new Bilgiler(); bilgi.kullaniciAdi = ""; bilgi.sifre = ""; bilgi.yonlenicektag = ""; userName.SendKeys(bilgi.kullaniciAdi); password.SendKeys(bilgi.sifre); girisbutonu.Click(); Thread.Sleep(9000); var gototagurl = "https://www.instagram.com/explore/tags/" + bilgi.yonlenicektag + "/"; driver.Navigate().GoToUrl(gototagurl); Thread.Sleep(3500); IWebElement firtpicture = driver.FindElement(By.CssSelector("._9AhH0")); firtpicture.Click(); while (true) { try { IWebElement prevnex = driver.FindElement(By.CssSelector("._65Bje.coreSpriteRightPaginationArrow")); prevnex.Click(); Thread.Sleep(2500); IWebElement followbtn = driver.FindElement(By.CssSelector(".sqdOP.yWX7d.y3zKF")); followbtn.Click(); Thread.Sleep(2500); } catch { } } var Followbtn = driver.FindElement(By.XPath("//button[. = 'Takip Et']")); Followbtn.Click(); } }
private static IWebDriver CreateChromeDriver(string driversDirectory) { var chromeService = Chrome.ChromeDriverService.CreateDefaultService(driversDirectory); chromeService.HideCommandPromptWindow = true; var chromeOptions = new Chrome.ChromeOptions { PageLoadStrategy = PageLoadStrategy.None }; chromeOptions.AddArgument("disable-infobars"); chromeOptions.AddArgument("--disable-bundled-ppapi-flash"); chromeOptions.AddArgument("--log-level=3"); chromeOptions.AddArgument("--silent"); chromeOptions.AddUserProfilePreference("credentials_enable_service", false); chromeOptions.AddUserProfilePreference("profile.password_manager_enabled", false); chromeOptions.AddUserProfilePreference("auto-open-devtools-for-tabs", false); return(new Chrome.ChromeDriver(chromeService, chromeOptions)); }
protected void btnLogin_Click(object sender, EventArgs e) { string strUserCode = txtUserCode.Text; string strPassword = txtPassword.Text; var options = new OpenQA.Selenium.Chrome.ChromeOptions(); options.AddArgument("headless"); var driver = new ChromeDriver(@"E:/Work/Demo/Driver/Chrome", options); //var driver = new OpenQA.Selenium.IE.InternetExplorerDriver(@"E:\Work\Demo\IEDriverServer_x64_2.39.0"); //driver.Navigate().GoToUrl("http://home.centurysurety.com/"); driver.Navigate().GoToUrl("https://gigezrate.guard.com/comm/asclogin/agents.htm"); //String ste = driver.PageSource; IWebElement eUserCode = driver.FindElement(By.Name("USER_CODE")); eUserCode.SendKeys(strUserCode); //eUserCode.SendKeys("jcorallo"); IWebElement ePassword = driver.FindElement(By.Name("PASSWORD")); ePassword.SendKeys(strPassword); //ePassword.SendKeys("Sasha5128"); driver.FindElement(By.XPath("//input[@value='Log in']")).Click(); driver.Navigate().GoToUrl("https://gigezrate.guard.com/dotnet/mvc/asc/ascheader/homepage/index"); //String ste1 = driver.PageSource; //string[] arr = Regex.Split(ste1, "</div>"); string strConect = ""; var doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(driver.PageSource); strConect = "<table>" + doc.GetElementbyId("TabContents").InnerHtml + "</table>"; string correctString = strConect.Replace("/dotnet/mvc/uw/ezrate/asc_prerate/home/Index?", "CreateQuoteGuard.aspx"); dvContent.InnerHtml = correctString; mvGuard.ActiveViewIndex = 1; //upnlContent.Update(); }
void OpenBrows() { ticktak.Start(); var driverService = ChromeDriverService.CreateDefaultService(); driverService.HideCommandPromptWindow = !consoleVisib.Checked; if (VisBrows == 0) { ChromeOptions SettingBr = new OpenQA.Selenium.Chrome.ChromeOptions(); SettingBr.AddArgument("headless"); Browser = new ChromeDriver(driverService, SettingBr); } else { Browser = new OpenQA.Selenium.Chrome.ChromeDriver(driverService); } Browser.Navigate().GoToUrl("http://moodle.dgma.donetsk.ua/login/index.php"); CheckBrows = 1; }
private void loadWebBrowser() { Chrome.ChromeDriverService driverSvc = Chrome.ChromeDriverService.CreateDefaultService(); driverSvc.HideCommandPromptWindow = true; Chrome.ChromeOptions ops = new Chrome.ChromeOptions(); //ops.AddArgument("--headless"); wbb = new Chrome.ChromeDriver(driverSvc, ops); //开启无头模式 //chrome_options = Options() //chrome_options.add_argument('--headless') //driver = webdriver.Chrome(chrome_options = chrome_options) //禁止显示命令行界面 //var cdSvc = ChromeDriverService.CreateDefaultService(); //cdSvc.HideCommandPromptWindow = true; //IWebDriver driver = new ChromeDriver(cdSvc); }
public IWebDriver CreateDriver() { string argumentLanguage = string.Format("--lang={0}", AppSettings.Settings.Locale); switch (AppSettings.Settings.Browser) { case Names.Chrome: OpenQA.Selenium.Chrome.ChromeOptions chromeOptions = new OpenQA.Selenium.Chrome.ChromeOptions(); chromeOptions.AddArguments(argumentLanguage); return(new ChromeDriver(chromeOptions)); case Names.FireFox: OpenQA.Selenium.Firefox.FirefoxOptions firefoxOptions = new OpenQA.Selenium.Firefox.FirefoxOptions(); firefoxOptions.AddArguments(argumentLanguage); return(new OpenQA.Selenium.Firefox.FirefoxDriver()); default: throw new ArgumentException($"Browser not yet implemented: {AppSettings.Settings.Browser}"); } }
private static DriverOptions getBrowserOptions(DriverConfig config) { DriverOptions opts; switch (config.Browser) { case "firefox": var ffOpts = new OpenQA.Selenium.Firefox.FirefoxOptions(); if (config.Headless) { ffOpts.AddArgument("--headless"); } ffOpts.LogLevel = FirefoxDriverLogLevel.Fatal; opts = ffOpts; break; case "chrome": var chromeOpts = new OpenQA.Selenium.Chrome.ChromeOptions(); if (config.Headless) { chromeOpts.AddArgument("--headless"); } chromeOpts.AddArgument("--log-level=3"); chromeOpts.AddArgument("--silent"); opts = chromeOpts; break; default: throw new NotImplementedException("Not implemented for browser: " + config.Browser); } opts.SetLoggingPreference(LogType.Browser, LogLevel.Off); opts.SetLoggingPreference(LogType.Driver, LogLevel.Off); opts.SetLoggingPreference(LogType.Client, LogLevel.Off); opts.SetLoggingPreference(LogType.Profiler, LogLevel.Off); opts.SetLoggingPreference(LogType.Server, LogLevel.Off); return(opts); }
public void StartAppAndOpenBrowser() { server = new TestServer(); server.StartTestServer(); // Create a headless Chrome browser. // ChromeOptions options = new ChromeOptions(); // options.AddArguments("--headless"); // driver = new ChromeDriver(options); OpenQA.Selenium.Chrome.ChromeOptions capability = new OpenQA.Selenium.Chrome.ChromeOptions(); capability.AddAdditionalCapability("os_version", "10", true); capability.AddAdditionalCapability("resolution", "1920x1080", true); capability.AddAdditionalCapability("browser", "Chrome", true); capability.AddAdditionalCapability("browser_version", "87.0", true); capability.AddAdditionalCapability("os", "Windows", true); capability.AddAdditionalCapability("name", "BStack-[C_sharp] Sample Test", true); // test name capability.AddAdditionalCapability("build", "BStack Build Number 1", true); // CI/CD job or build name capability.AddAdditionalCapability("browserstack.user", "sanketmali4", true); capability.AddAdditionalCapability("browserstack.key", "XaqpcHttuyFzXSzC3uNM", true); driver = new RemoteWebDriver( new Uri("https://hub-cloud.browserstack.com/wd/hub/"), capability); //driver = new ChromeDriver(options); percy = new Percy(driver); }
public static void FindTheUnf() { var options = new OpenQA.Selenium.Chrome.ChromeOptions(); options.BinaryLocation = @"C:\Program Files\Google\Chrome\Application\chrome.exe"; using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(options)) { var UnfList = new List <string>(); var followerList = new List <string>(); var followList = new List <string>(); var bilgi = Login(driver); var follwersWebElement = Takipçiler(bilgi, driver); Thread.Sleep(7000); foreach (IWebElement item in follwersWebElement) { followerList.Add(item.Text); } var followWebElement = TakipEttiklerim(bilgi, driver); foreach (IWebElement item in followWebElement) { followList.Add(item.Text); } foreach (var item in followList) { if (followerList.Where(x => x == item).Count() <= 0) { UnfList.Add(item); Console.WriteLine(item); } } } Console.ReadKey(); }
public SpecCompliantChromeDriver(ChromeDriverService service, ChromeOptions options) : base(service, options) { }
private QA.IWebDriver InitWebDriver(string cache_dir, bool loadImage = true, string useragent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36") { if (!Directory.Exists(cache_dir)) { Directory.CreateDirectory(cache_dir); } QA.IWebDriver theDriver = null; switch (this.browser) { case Browsers.IE: { InternetExplorerDriverService driverService = InternetExplorerDriverService.CreateDefaultService(Application.StartupPath + "\\Drivers\\"); driverService.HideCommandPromptWindow = true; driverService.SuppressInitialDiagnosticInformation = true; ds = driverService; QA.IE.InternetExplorerOptions _ieOptions = new QA.IE.InternetExplorerOptions(); _ieOptions.IntroduceInstabilityByIgnoringProtectedModeSettings = true; theDriver = new QA.IE.InternetExplorerDriver(driverService, _ieOptions); _ProcessID = driverService.ProcessId; }; break; case Browsers.Chrome: { ChromeDriverService driverService = ChromeDriverService.CreateDefaultService(Application.StartupPath + "\\Drivers\\"); driverService.Port = new Random().Next(1000, 2000); driverService.HideCommandPromptWindow = true; driverService.SuppressInitialDiagnosticInformation = true; ds = driverService; ChromeOptions options = new QA.Chrome.ChromeOptions(); options.AddArgument("--window-size=" + Screen.PrimaryScreen.WorkingArea.Width + "x" + Screen.PrimaryScreen.WorkingArea.Height); options.AddArgument("--disable-gpu"); options.AddArgument("--disable-extensions"); options.AddArgument("--no-sandbox"); options.AddArgument("--disable-dev-shm-usage"); options.AddArgument("--disable-java"); options.AddArgument("--user-agent=" + useragent); options.AddArgument(@"--user-data-dir=" + cache_dir); if (loadImage == false) { options.AddUserProfilePreference("profile.managed_default_content_settings.images", 2); //不加载图片 } theDriver = new QA.Chrome.ChromeDriver(driverService, options, TimeSpan.FromSeconds(240)); _ProcessID = driverService.ProcessId; }; break; case Browsers.Firefox: { var driverService = FirefoxDriverService.CreateDefaultService(Application.StartupPath + "\\Drivers\\"); driverService.HideCommandPromptWindow = true; driverService.SuppressInitialDiagnosticInformation = true; ds = driverService; FirefoxProfile profile = new FirefoxProfile(); if (loadImage == false) { profile.SetPreference("permissions.default.image", 2); // 关掉flash profile.SetPreference("dom.ipc.plugins.enabled.libflashplayer.so", false); } FirefoxOptions options = new FirefoxOptions(); options.Profile = profile; theDriver = new QA.Firefox.FirefoxDriver(driverService, options, TimeSpan.FromMinutes(240)); _ProcessID = driverService.ProcessId; }; break; case Browsers.Safari: { SafariDriverService driverService = SafariDriverService.CreateDefaultService(Application.StartupPath + "\\Drivers\\"); driverService.HideCommandPromptWindow = true; driverService.SuppressInitialDiagnosticInformation = true; ds = driverService; theDriver = new QA.Safari.SafariDriver(driverService); _ProcessID = driverService.ProcessId; }; break; default: { QA.IE.InternetExplorerOptions _ieOptions = new QA.IE.InternetExplorerOptions(); _ieOptions.IntroduceInstabilityByIgnoringProtectedModeSettings = true; theDriver = new QA.IE.InternetExplorerDriver(_ieOptions); }; break; } //theDriver.Manage().Window.Maximize(); return(theDriver); }
/// <summary> /// Initializes a new instance of the <see cref="ChromeDriver"/> class using the specified <see cref="ChromeDriverService"/>. /// </summary> /// <param name="service">The <see cref="ChromeDriverService"/> to use.</param> /// <param name="options">The <see cref="ChromeOptions"/> to be used with the Chrome driver.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public ChromeDriver(ChromeDriverService service, ChromeOptions options, TimeSpan commandTimeout) : base(new DriverServiceCommandExecutor(service, commandTimeout), options.ToCapabilities()) { }
/// <summary> /// Initializes a new instance of the <see cref="ChromeDriver"/> class using the specified path /// to the directory containing ChromeDriver.exe and options. /// </summary> /// <param name="chromeDriverDirectory">The full path to the directory containing ChromeDriver.exe.</param> /// <param name="options">The <see cref="ChromeOptions"/> to be used with the Chrome driver.</param> public ChromeDriver(string chromeDriverDirectory, ChromeOptions options) : this(chromeDriverDirectory, options, RemoteWebDriver.DefaultCommandTimeout) { }
/// <summary> /// Initializes a new instance of the <see cref="ChromeDriver"/> class using the specified path /// to the directory containing ChromeDriver.exe, options, and command timeout. /// </summary> /// <param name="chromeDriverDirectory">The full path to the directory containing ChromeDriver.exe.</param> /// <param name="options">The <see cref="ChromeOptions"/> to be used with the Chrome driver.</param> /// <param name="commandTimeout">The maximum amount of time to wait for each command.</param> public ChromeDriver(string chromeDriverDirectory, ChromeOptions options, TimeSpan commandTimeout) : this(ChromeDriverService.CreateDefaultService(chromeDriverDirectory), options, commandTimeout) { }
/// <summary> /// Initializes a new instance of the <see cref="ChromeDriver"/> class using the specified /// <see cref="ChromeDriverService"/> and options. /// </summary> /// <param name="service">The <see cref="ChromeDriverService"/> to use.</param> /// <param name="options">The <see cref="ChromeOptions"/> used to initialize the driver.</param> public ChromeDriver(ChromeDriverService service, ChromeOptions options) : this(service, options, RemoteWebDriver.DefaultCommandTimeout) { }
/// <summary> /// Initializes a new instance of the <see cref="ChromeDriver"/> class using the specified options. /// </summary> /// <param name="options">The <see cref="ChromeOptions"/> to be used with the Chrome driver.</param> public ChromeDriver(ChromeOptions options) : this(ChromeDriverService.CreateDefaultService(), options, RemoteWebDriver.DefaultCommandTimeout) { }
private QA.IWebDriver InitWebDriver() { QA.IWebDriver theDriver = null; switch (this.browser) { case Browsers.IE: { InternetExplorerDriverService driverService = InternetExplorerDriverService.CreateDefaultService(Application.StartupPath + "\\drivers\\"); driverService.HideCommandPromptWindow = true; driverService.SuppressInitialDiagnosticInformation = true; ds = driverService; QA.IE.InternetExplorerOptions _ieOptions = new QA.IE.InternetExplorerOptions(); _ieOptions.IntroduceInstabilityByIgnoringProtectedModeSettings = true; theDriver = new QA.IE.InternetExplorerDriver(driverService, _ieOptions); ProcessID = driverService.ProcessId; }; break; case Browsers.PhantomJS: { PhantomJSDriverService driverService = PhantomJSDriverService.CreateDefaultService(Application.StartupPath + "\\Drivers\\"); driverService.HideCommandPromptWindow = true; driverService.SuppressInitialDiagnosticInformation = true; ds = driverService; theDriver = new QA.PhantomJS.PhantomJSDriver(driverService); }; break; case Browsers.Chrome: { ChromeDriverService driverService = ChromeDriverService.CreateDefaultService(Application.StartupPath + "\\drivers\\"); driverService.HideCommandPromptWindow = true; driverService.SuppressInitialDiagnosticInformation = true; ds = driverService; ChromeOptions options = new QA.Chrome.ChromeOptions(); options.AddUserProfilePreference("profile.managed_default_content_settings.images", _IsLoadPicture ? 1 : 2); options.AddUserProfilePreference("profile.managed_default_content_settings.javascript", _IsLoadJS ? 1 : 2); //options.AddArgument(@"--user-data-dir=" + cache_dir); //string dir = string.Format(@"user-data-dir={0}", ConfigManager.GetInstance().UserDataDir); //options.AddArguments(dir); //options.AddArgument("--no-sandbox"); //options.AddArgument("--disable-dev-shm-usage"); //options.AddArguments("--disable-extensions"); // to disable extension //options.AddArguments("--disable-notifications"); // to disable notification //options.AddArguments("--disable-application-cache"); // to disable cache try { if (_timeout == 60) { theDriver = new QA.Chrome.ChromeDriver(driverService, options, new TimeSpan(0, 0, 40)); } else { theDriver = new QA.Chrome.ChromeDriver(driverService, options, new TimeSpan(0, 0, _timeout)); } } catch (Exception ex) { } ProcessID = driverService.ProcessId; }; break; case Browsers.Firefox: { var driverService = FirefoxDriverService.CreateDefaultService(Application.StartupPath + "\\drivers\\"); driverService.HideCommandPromptWindow = true; driverService.SuppressInitialDiagnosticInformation = true; ds = driverService; FirefoxProfile profile = new FirefoxProfile(); try { if (_doproxy == "1") { string proxy = ""; try { if (_IsUseNewProxy == false) { proxy = GetProxyA(); } else { //TO DO 获取芝麻代理 hi.URL = "http:......?你的代理地址"; // ConfigManager.GetInstance().ProxyUrl; hr = hh.GetContent(hi); if (hr.StatusCode == System.Net.HttpStatusCode.OK) { if (hr.Content.Contains("您的套餐余量为0")) { proxy = ""; } if (hr.Content.Contains("success") == false) { proxy = ""; } JObject j = JObject.Parse(hr.Content); foreach (var item in j) { foreach (var itemA in item.Value) { if (itemA.ToString().Contains("expire_time")) { if (DateTime.Now.AddHours(2) < DateTime.Parse(itemA["expire_time"].ToString())) { proxy = itemA["ip"].ToString() + ":" + itemA["port"].ToString(); break; } } } if (proxy != "") { break; } } } } } catch (Exception ex) { } if (proxy != "" && proxy.Contains(":")) { OpenQA.Selenium.Proxy proxyF = new OpenQA.Selenium.Proxy(); proxyF.HttpProxy = proxy; proxyF.FtpProxy = proxy; proxyF.SslProxy = proxy; profile.SetProxyPreferences(proxyF); // 使用代理 profile.SetPreference("network.proxy.type", 1); //ProxyUser-通行证书 ProxyPass-通行密钥 profile.SetPreference("username", "你的账号"); profile.SetPreference("password", "你的密码"); // 所有协议公用一种代理配置,如果单独配置,这项设置为false profile.SetPreference("network.proxy.share_proxy_settings", true); // 对于localhost的不用代理,这里必须要配置,否则无法和webdriver通讯 profile.SetPreference("network.proxy.no_proxies_on", "localhost"); } } } catch (Exception ex) { } //profile.SetPreference("permissions.default.image", 2); // 关掉flash profile.SetPreference("dom.ipc.plugins.enabled.libflashplayer.so", false); FirefoxOptions options = new FirefoxOptions(); options.Profile = profile; theDriver = new QA.Firefox.FirefoxDriver(driverService, options, TimeSpan.FromMinutes(1)); ProcessID = driverService.ProcessId; }; break; case Browsers.Safari: { SafariDriverService driverService = SafariDriverService.CreateDefaultService(Application.StartupPath + "\\Drivers\\"); driverService.HideCommandPromptWindow = true; driverService.SuppressInitialDiagnosticInformation = true; ds = driverService; theDriver = new QA.Safari.SafariDriver(driverService); ProcessID = driverService.ProcessId; }; break; default: { QA.IE.InternetExplorerOptions _ieOptions = new QA.IE.InternetExplorerOptions(); _ieOptions.IntroduceInstabilityByIgnoringProtectedModeSettings = true; theDriver = new QA.IE.InternetExplorerDriver(_ieOptions); }; break; } return(theDriver); }
public DevChannelChromeDriver(ChromeDriverService service, ChromeOptions options) : base(service, options) { }
protected void btnLoadContent_Click(object sender, EventArgs e) { //lblMsg.Text = "Please wait."; //mpShow.Show(); var options = new OpenQA.Selenium.Chrome.ChromeOptions(); options.AddArgument("headless"); var driver = new ChromeDriver(@"E:/Work/Demo/Driver/Chrome", options); //var driver = new OpenQA.Selenium.IE.InternetExplorerDriver(@"E:\Work\Demo\IEDriverServer_x64_2.39.0"); //driver.Navigate().GoToUrl("http://home.centurysurety.com/"); driver.Navigate().GoToUrl("https://gigezrate.guard.com/comm/asclogin/agents.htm"); //String ste = driver.PageSource; IWebElement eUserCode = driver.FindElement(By.Name("USER_CODE")); eUserCode.SendKeys("jcorallo"); IWebElement ePassword = driver.FindElement(By.Name("PASSWORD")); ePassword.SendKeys("Sasha5128"); driver.FindElement(By.XPath("//input[@value='Log in']")).Click(); //driver.Navigate().GoToUrl("https://gigezrate.guard.com/dotnet/mvc/asc/ascheader/homepage/index"); driver.Navigate().GoToUrl("https://gigezrate.guard.com/dotnet/mvc/uw/ezrate/asc_prerate/home/Index?"); String strPageSource = driver.PageSource; //if (ste1.StartsWith("gtmvcform_")) //{ // // Will match second possibility. // Console.WriteLine(s); // return; //} //string test = ste1; //int index1 = test.IndexOf("gtmvcform_"); //if (index1 != -1) //{ // string result2 = test.Remove(index1); //} //string s = driver.PageSource; string strFormID = string.Empty; if (strPageSource.Contains("gtmvcform_")) { int x = strPageSource.IndexOf("gtmvcform_"); int t = strPageSource.Substring(x).IndexOf(" "); strFormID = strPageSource.Substring(x, t); } strFormID = strFormID.Replace("\"", ""); //New Code HtmlDocument doc1 = new HtmlDocument(); doc1.LoadHtml(driver.PageSource); // HtmlNode secondForm = doc1.GetElementbyId(strFormID); string strPagecontent = string.Empty; doc1.DocumentNode.Descendants() .Where(n => n.Id == "presubmissionlist_lnk_div") .ToList() .ForEach(n => n.Remove()); string classToFind = "GTtabBox"; var allElementsWithClass = doc1.DocumentNode.SelectNodes(string.Format("//*[contains(@class,'{0}')]", classToFind)); foreach (var item in allElementsWithClass) { strPagecontent += item.InnerHtml; } string strPagecontent1 = allElementsWithClass[0].InnerHtml; string strPagecontent3 = allElementsWithClass[3].InnerHtml; HtmlAgilityPack.HtmlNodeCollection ScriptNodes = doc1.DocumentNode.SelectNodes("//script"); HtmlAgilityPack.HtmlNodeCollection StyleNodes = doc1.DocumentNode.SelectNodes("//link"); string correctString = string.Empty; foreach (HtmlNode node in ScriptNodes) { correctString += node.OuterHtml; } foreach (HtmlNode node in StyleNodes) { correctString += node.OuterHtml; } string correctString1 = correctString.Replace("/dotnet/mvc/", "https://gigezrate.guard.com/dotnet/mvc/"); //New code //var doc = new HtmlAgilityPack.HtmlDocument(); //doc.LoadHtml(driver.PageSource); //string strConect = doc.GetElementbyId(strFormID).InnerHtml; //string correctString = strConect.Replace("/dotnet/mvc/uw/ezrate/asc_prerate/home/Index?", "CreateQuoteGuard.aspx"); strPagecontent3 = strPagecontent3 + correctString1; //HtmlDocument doc = new HtmlDocument(); //doc.LoadHtml(strPagecontent3); //HtmlAgilityPack.HtmlNodeCollection divNodes = doc1.DocumentNode.SelectNodes("//div"); //foreach (HtmlNode node in divNodes) //{ // if() //} //doc1.DocumentNode.Descendants() // .Where(n => n.Id == "presubmissionlist_lnk_div") // .ToList() // .ForEach(n => n.Remove()); dvContent.InnerHtml = strPagecontent3; }
public static void İnstagramKayit() { var options = new OpenQA.Selenium.Chrome.ChromeOptions(); var proxy = new Proxy(); proxy.HttpProxy = "111.90.179.74:8080"; options.Proxy = proxy; options.BinaryLocation = @"C:\Program Files\Google\Chrome\Application\chrome.exe"; using (IWebDriver driver = new OpenQA.Selenium.Chrome.ChromeDriver(options)) { #region Tempmail driver.Navigate().GoToUrl("https://tr.emailfake.com/"); var tempmail = ""; try { tempmail = driver.FindElement(By.Id("userName")).GetAttribute("value") + "@" + driver.FindElement(By.Id("domainName2")).GetAttribute("value"); } catch (Exception ex) { Console.WriteLine(ex.Message); } #endregion #region instagramkayıt ((IJavaScriptExecutor)driver).ExecuteScript("window.open();"); driver.SwitchTo().Window(driver.WindowHandles.Last()); driver.Navigate().GoToUrl("https://www.instagram.com/accounts/emailsignup/"); Thread.Sleep(2000); IWebElement email = driver.FindElement(By.Name("emailOrPhone")); IWebElement fullname = driver.FindElement(By.Name("fullName")); IWebElement username = driver.FindElement(By.Name("username")); IWebElement password = driver.FindElement(By.Name("password")); IWebElement Kayıtbutton = driver.FindElement(By.XPath("//button[. = 'Kaydol']")); User user = new User(); user.adsoyad = "sohistory14"; user.eposta = tempmail; user.kullaniciadi = "sohistory14"; user.sifre = "historyso2q"; email.SendKeys(user.eposta); fullname.SendKeys(user.adsoyad); username.SendKeys(user.kullaniciadi); password.SendKeys(user.sifre); Kayıtbutton.Click(); Thread.Sleep(5000); SelectElement oSelect = new SelectElement(driver.FindElement(By.XPath("//*[@title='Ay:']"))); oSelect.SelectByText("Mayıs"); SelectElement oSelect2 = new SelectElement(driver.FindElement(By.XPath("//*[@title='Gün:']"))); oSelect2.SelectByText("1"); SelectElement oSelect3 = new SelectElement(driver.FindElement(By.XPath("//*[@title='Yıl:']"))); oSelect3.SelectByText("1998"); IWebElement ileributton = driver.FindElement(By.XPath("//button[. = 'İleri']")); ileributton.Click(); IWebElement body2 = driver.FindElement(By.TagName("body")); body2.SendKeys(Keys.Alt + Keys.Tab); driver.SwitchTo().Window(driver.WindowHandles.First()); #endregion var codelink = ""; var sayaç = 0; while (true) { try { if (!string.IsNullOrEmpty(codelink)) { Thread.Sleep(2500); driver.SwitchTo().Window(driver.WindowHandles.Last()); IWebElement kodutekrargonder = driver.FindElement(By.XPath("//button[. = 'Kodu Tekrar Gönder.']")); kodutekrargonder.Click(); Thread.Sleep(2500); driver.SwitchTo().Window(driver.WindowHandles.First()); sayaç = 0; } codelink = driver.FindElement(By.CssSelector("#email_content > table > tbody > tr:nth-child(4) > td > table > tbody > tr > td > table > tbody > tr:nth-child(2) > td:nth-child(2) > table > tbody > tr:nth-child(2) > td:nth-child(2)")).GetAttribute("innerHTML"); break; } catch (Exception ex) { Console.WriteLine(ex.Message); } } driver.SwitchTo().Window(driver.WindowHandles.Last()); try { IWebElement emailconfirmationcode = driver.FindElement(By.Name("email_confirmation_code")); emailconfirmationcode.SendKeys(codelink); IWebElement Kayıtbuttonİleri = driver.FindElement(By.XPath("//button[. = 'İleri']")); Kayıtbuttonİleri.Click(); } catch (Exception ex) { Console.WriteLine(ex.Message); } Thread.Sleep(20000); Console.ReadKey(); } }
private static IWebDriver CreateNewWebDriver(string webBrowserName, BrowserType type, out IntPtr mainWindowHandle, string driversDirectory) { webBrowserName = webBrowserName.ToLower(); IWebDriver iWebDriver = null; List <Process> processesBeforeLaunch = GetProcesses(); string newProcessFilter = string.Empty; switch (type) { case BrowserType.Chrome: var chromeService = Chrome.ChromeDriverService.CreateDefaultService(driversDirectory); chromeService.HideCommandPromptWindow = true; var chromeOptions = new Chrome.ChromeOptions(); chromeOptions.PageLoadStrategy = PageLoadStrategy.None; chromeOptions.AddArgument("disable-infobars"); chromeOptions.AddArgument("--disable-bundled-ppapi-flash"); chromeOptions.AddArgument("--log-level=3"); chromeOptions.AddArgument("--silent"); chromeOptions.AddUserProfilePreference("credentials_enable_service", false); chromeOptions.AddUserProfilePreference("profile.password_manager_enabled", false); chromeOptions.AddUserProfilePreference("auto-open-devtools-for-tabs", false); //chromeOptions.AddAdditionalCapability("pageLoadStrategy", "none", true); iWebDriver = new Chrome.ChromeDriver(chromeService, chromeOptions); newProcessFilter = "chrome"; break; case BrowserType.Firefox: var firefoxService = Firefox.FirefoxDriverService.CreateDefaultService(driversDirectory); firefoxService.HideCommandPromptWindow = true; iWebDriver = new Firefox.FirefoxDriver(firefoxService); newProcessFilter = "firefox"; break; case BrowserType.InternetExplorer: IE.InternetExplorerDriverService ieService = IE.InternetExplorerDriverService.CreateDefaultService(driversDirectory); ieService.HideCommandPromptWindow = true; IE.InternetExplorerOptions options = new IE.InternetExplorerOptions() { IgnoreZoomLevel = true }; iWebDriver = new IE.InternetExplorerDriver(ieService, options); newProcessFilter = "iexplore"; break; case BrowserType.Edge: var edgeService = Edge.EdgeDriverService.CreateDefaultService(driversDirectory); edgeService.HideCommandPromptWindow = true; var edgeOptions = new Edge.EdgeOptions(); edgeOptions.PageLoadStrategy = PageLoadStrategy.Eager; iWebDriver = new Edge.EdgeDriver(edgeService, edgeOptions); newProcessFilter = "edge"; break; default: throw new ArgumentException($"Could not launch specified browser '{webBrowserName}'"); } var newProcess = GetNewlyCreatedProcesses(newProcessFilter, processesBeforeLaunch); mainWindowHandle = (newProcess != null) ? newProcess.MainWindowHandle : IntPtr.Zero; return(iWebDriver); }
private IWebDriver GetDriver(DriverTypes type) { IWebDriver driver = null; switch (type) { case DriverTypes.IE: driver = new InternetExplorerDriver( new InternetExplorerOptions { UnexpectedAlertBehavior = InternetExplorerUnexpectedAlertBehavior.Default, EnableNativeEvents = true, //ForceCreateProcessApi = true, //BrowserCommandLineArguments = "-private", EnsureCleanSession = true }); driver = new NgWebDriver(driver); break; case DriverTypes.Chrome: ChromeOptions options = new ChromeOptions(); options.AddArgument("--disable-plugins"); driver = new ChromeDriver(options); driver = new NgWebDriver(driver); break; } ((NgWebDriver)driver).IgnoreSynchronization = true; return driver; }