public static void GrabAllLinks() { var profileManager = new FirefoxProfileManager(); var profile = profileManager.GetProfile("Test"); var firefoxService = FirefoxDriverService.CreateDefaultService(); var options = new FirefoxOptions() { Profile = profile }; var driver = new FirefoxDriver(firefoxService, options, new TimeSpan(0, 0, 30)); driver.Navigate().GoToUrl("http://audioclub.top/"); var htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(driver.PageSource); var elements = htmlDocument.DocumentNode.SelectNodesNoFail(".//li[contains(@class,'cat-item')]//a"); var links = new HashSet <string>(); foreach (var element in elements) { links.Add(Regex.Match(element.Attributes["href"].Value, @"http://audioclub.top/category/([^/]*)/").Groups[1].Captures[0].Value); Console.WriteLine("Found company {0}", element.InnerText); } links.Add("plugin"); var contents = links.Aggregate("", (current, company) => current + GrabLinks(company, driver)); File.WriteAllText($@"{Paths.ListsPath}\All.txt", contents); }
public static IWebDriver GetInstance() { if (driver == null) { TestConfigurations configs = TestConfigurations.GetInstance(); if (TestConfigurations.Browser == chrome) { ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.AcceptInsecureCertificates = true; driver = new ChromeDriver(); } else if (TestConfigurations.Browser == firefox) { var profileManager = new FirefoxProfileManager(); FirefoxProfile profile = profileManager.GetProfile("myNewProfile"); profile.AcceptUntrustedCertificates = true; FirefoxOptions options = new FirefoxOptions(); options.Profile = profile; driver = new FirefoxDriver(options); } else if (TestConfigurations.Browser == internetExplorer) { driver = new InternetExplorerDriver(); } else { throw new Exception("Invalid browser in the settings"); } } return(driver); }
public FirefoxOptions UseBrowserConfigurationForFirefox() { FirefoxProfile myProfile = new FirefoxProfileManager().GetProfile("default"); if (myProfile == null) { throw new Exception("default firefox profile does not exist, please create it first."); } myProfile.AcceptUntrustedCertificates = true; myProfile.AssumeUntrustedCertificateIssuer = true; myProfile.SetPreference("browser.cache.memory.enable", false); myProfile.SetPreference("browser.cache.offline.enable", false); myProfile.SetPreference("browser.cache.disk.enable", false); myProfile.SetPreference("network.http.use - cache", false); FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.AddArguments("--headless"); firefoxOptions.AddArguments("--window-size=1920,1080"); firefoxOptions.LogLevel = FirefoxDriverLogLevel.Trace; firefoxOptions.Profile = myProfile; return(firefoxOptions); }
public Web() { FirefoxProfileManager allProfiles = new FirefoxProfileManager(); //FirefoxProfile profile = allProfiles.GetProfile( //TODO: Read the browser type from an external configuration file. string driverTypeProp = Sut.Instance.GetProperty("webdriver", "browser"); if (driverTypeProp.ToLower().Equals("chrome")) { driver = WebdriverFactory.CreateDriver(Webdriver_infra.WebdriverFactory.DriverType.Chrome, null); driver.Manage().Window.Size = new System.Drawing.Size(1920, 1080); } else if (driverTypeProp.ToLower().Equals("iexplore") || driverTypeProp.ToLower().Equals("explorer") || driverTypeProp.ToLower().Equals("explore") || driverTypeProp.ToLower().Equals("internetexplorer")) { driver = WebdriverFactory.CreateDriver(Webdriver_infra.WebdriverFactory.DriverType.InternetExplorer, null); } else if (driverTypeProp.ToLower().Equals("firefox")) { driver = WebdriverFactory.CreateDriver(Webdriver_infra.WebdriverFactory.DriverType.Firefox, null); } driver.Manage().Window.Maximize(); driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(30)); driver.Navigate().GoToUrl(Url); }
}; // Keyword list static void Main(string[] args) { #region Input Console.Write("Please type your direction to text file: "); string link_dir = Console.ReadLine(); string tmp; do { Console.Write("Please insert your key word (To stop type 'Done'): "); tmp = Console.ReadLine(); if (tmp != "Done") { key_lists.Add(tmp); } } while (tmp != "Done"); #endregion // Solution FirefoxProfileManager profile_manager = new FirefoxProfileManager(); FirefoxProfile profile = profile_manager.GetProfile("Selenium"); // "Selenium" is my profile name in Firefox, you need to create something similar otherwise Firefox will use Default profile IWebDriver driver = new FirefoxDriver(profile); string line; System.IO.StreamReader file = new System.IO.StreamReader(link_dir); //Link to text file while ((line = file.ReadLine()) != null) { Process(line, driver); } file.Close(); driver.Close(); Console.ReadLine(); }
private void OpenBrowser() { FirefoxProfileManager profilemanager = new FirefoxProfileManager(); FirefoxProfile profile = (profilemanager.GetProfile("123"));//pathsToProfiles[0]); driver = new FirefoxDriver(new FirefoxBinary(@"FF\firefox.exe"), profile); }
private static FirefoxProfile GetFirefoxProfile() { FirefoxProfile profile = new FirefoxProfile(); FirefoxProfileManager manager = new FirefoxProfileManager(); return(profile); }
public void SetupTest() { // 7. Use specific Firefox Profile var profileManager = new FirefoxProfileManager(); FirefoxProfile profile = profileManager.GetProfile("HARDDISKUSER"); var firefoxOptions = new FirefoxOptions(); firefoxOptions.Profile = profile; _driver = new FirefoxDriver(firefoxOptions); // 7.1. Set Chrome Options. ChromeOptions options = new ChromeOptions(); options.AcceptInsecureCertificates = true; options.UnhandledPromptBehavior ////// set some options ////DesiredCapabilities dc = DesiredCapabilities.Chrome(); ////dc.SetCapability(ChromeOptions.Capability, options); ////IWebDriver driver = new RemoteWebDriver(dc); // 8. Turn off Java Script ////FirefoxProfileManager profileManager = new FirefoxProfileManager(); ////FirefoxProfile profile = profileManager.GetProfile("HARDDISKUSER"); ////profile.SetPreference("javascript.enabled", false); ////this.driver = new FirefoxDriver(profile); ////this.driver = new FirefoxDriver(); ////var options = new InternetExplorerOptions(); ////options.EnsureCleanSession = true; ////options.IgnoreZoomLevel = true; ////options.EnableNativeEvents = true; ////options.PageLoadStrategy = InternetExplorerPageLoadStrategy.Eager; ////this.driver = new InternetExplorerDriver(@"D:\Projects\PatternsInAutomation.Tests\WebDriver.Series.Tests\Drivers", options); _driver = new FirefoxDriver(); _driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(30); }
public IWebDriver StartBrowser(string browserType) { switch (browserType) { case ("Chrome"): driver = new ChromeDriver(); return(driver); break; case ("Firefox"): //FIREFOX with lame untrusted certificate exception workaround FirefoxProfileManager ffprofmanager = new FirefoxProfileManager(); FirefoxProfile firefoxProfile = ffprofmanager.GetProfile(firefoxProfileName); firefoxProfile.AcceptUntrustedCertificates = true; firefoxProfile.AssumeUntrustedCertificateIssuer = false; return(new FirefoxDriver(firefoxProfile)); break; default: driver = new ChromeDriver(); return(driver); } return(driver); }
public SeleniumBrowser() { FirefoxProfile myprofile = new FirefoxProfileManager().GetProfile("mySeleniumProject"); driver = new FirefoxDriver(myprofile); homeWindowName = driver.WindowHandles.Last(); }
public void EscolherBrowser(string browser) { switch (browser) { case "Chrome": var options = new ChromeOptions(); options.AddUserProfilePreference("credentials_enable_service", false); options.AddUserProfilePreference("password_manager_enabled", false); Driver = new ChromeDriver(options); ConfigurarBrowser(); ScenarioContext.Current["Driver"] = Driver; break; case "Firefox": var profilePadrao = new FirefoxProfileManager(); FirefoxProfile profile = profilePadrao.GetProfile("Selenium"); Driver = new FirefoxDriver(profile); ConfigurarBrowser(); ScenarioContext.Current["Driver"] = Driver; break; case "IE": Driver = new InternetExplorerDriver(); ConfigurarBrowser(); ScenarioContext.Current["driver"] = Driver; break; default: Driver = new ChromeDriver(); ConfigurarBrowser(); ScenarioContext.Current["Driver"] = Driver; break; } }
private static FirefoxProfile GetFirefoxOptions() { var fOptions = new FirefoxProfile(); var fxManager = new FirefoxProfileManager(); fOptions = fxManager.GetProfile("default"); return(fOptions); }
private static FirefoxProfile GetFirefoxoptions() { FirefoxProfile profile = new FirefoxProfile(); FirefoxProfileManager manager = new FirefoxProfileManager(); profile = manager.GetProfile("default"); return(profile); }
private static FirefoxProfile GetFirefoxProfile() { FirefoxProfile profile = new FirefoxProfile(); FirefoxProfileManager manager = new FirefoxProfileManager(); profile = manager.GetProfile("chaaru1001"); return(profile); }
private static FirefoxProfile GetFirefoxOption() { var FProfile = new FirefoxProfile(); FirefoxProfileManager fxManager = new FirefoxProfileManager(); FProfile = fxManager.GetProfile("default"); return(FProfile); }
private void InstaWorker(int accountId) { string listenBox1 = Convert.ToString(listBox1.Items[accountId]); string[] AccPwdMailPwd = listenBox1.Split(':'); string listenBox2 = Convert.ToString(listBox2.Items[accountId]); string[] ProxyPortLoginpPwdP = listenBox2.Split(':'); var profileManager = new FirefoxProfileManager(); FirefoxProfile profileInstagram = profileManager.GetProfile("Selenium"); String PROXY = ProxyPortLoginpPwdP[0] + ":" + ProxyPortLoginpPwdP[1]; Proxy proxy = new Proxy() { HttpProxy = PROXY, // FtpProxy = PROXY, // SslProxy = PROXY, }; profileInstagram.SetProxyPreferences(proxy); FirefoxDriver browserInstagram = new FirefoxDriver(profileInstagram); Thread.Sleep(5000); browserInstagram.FindElement(By.XPath("//input[@name='username']"), 5).SendKeys(AccPwdMailPwd[0]); browserInstagram.FindElement(By.XPath("//input[@name='password']"), 5).SendKeys(AccPwdMailPwd[1]); //ListBox1Item2(instapwd) browserInstagram.FindElement(By.XPath("//*[@id=\"react-root\"]//section//main//div//article//div//div[1]//div//form//span//button"), 5).Click(); // InstaLoginButton // var cookies = listBox5.Items[accountId].ToString().Split(':'); // string[] CookMember = cookies[8].Split(';'); // string sessionId = cookies[9]; browserInstagram.Navigate().GoToUrl("https://" + ProxyPortLoginpPwdP[2] + ":" + ProxyPortLoginpPwdP[3] + "@instagram.com/accounts/login/"); //Good http://username:[email protected] Thread.Sleep(5000); browserInstagram.Navigate().GoToUrl("https://" + ProxyPortLoginpPwdP[2] + ":" + ProxyPortLoginpPwdP[3] + "@/p/BXioaw6B9uX/?taken-by=l4paley"); //Good http://username:[email protected] Thread.Sleep(3000); browserInstagram.FindElement(By.XPath("//*[@id=\"react-root\"]//section//main//div//div//article//div[2]//section[1]//a[1]")).Click(); Thread.Sleep(500); browserInstagram.Close(); //browserInstagram.WebStorage.SessionStorage.SetItem //browserInstagram.Manage().Cookies.DeleteAllCookies(); //browserInstagram.Manage().Cookies.AddCookie(new Cookie("sessionid", //sessionId)); /*foreach (var Cookie in CookMember) * { * var data = Cookie.Split(new[] { '=' }, 2); * browserInstagram.Manage().Cookies.AddCookie(new Cookie(data[0].Trim(), data[1].Trim())); * Console.WriteLine(data[0].Trim()); * Console.WriteLine(data[1].Trim()); * } *///Browser2.Navigate().GoToUrl("https://" + ProxyPortLoginpPwdP[2] + ":" + ProxyPortLoginpPwdP[3] + "@mail.ru"); //Good // browserInstagram.Navigate().GoToUrl("https://" + ProxyPortLoginpPwdP[2] + ":" + ProxyPortLoginpPwdP[3] + "@instagram.com"); Thread.Sleep(3000); }
public DriverFixture(IMessageSink messageSink) { try { Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); var testWebBrowser = Environment.GetEnvironmentVariable("TestWebBrowser") ?? "Chrome"; messageSink.OnMessage(new DiagnosticMessage($"TestWebBrowser = {testWebBrowser}")); if (testWebBrowser == "Firefox") { var profiles = new FirefoxProfileManager(); var profile = profiles.GetProfile("selenium"); messageSink.OnMessage(new DiagnosticMessage("Profiles:")); foreach (var existingProfile in profiles.ExistingProfiles) { messageSink.OnMessage(new DiagnosticMessage($"Profile = {existingProfile}")); } var options = new FirefoxOptions { Profile = profile }; options.SetLoggingPreference(LogType.Browser, LogLevel.All); Driver = new FirefoxDriver(FirefoxDriverService.CreateDefaultService(Environment.CurrentDirectory), new FirefoxOptions { Profile = profile }, TimeSpan.FromSeconds(30)); } else if (testWebBrowser == "IE") { Driver = new InternetExplorerDriver(Environment.CurrentDirectory); } else if (testWebBrowser == "Chrome") { Driver = new ChromeDriver(Environment.CurrentDirectory); } Driver.Manage().Window.Position = new Point(0, 0); Driver.Manage().Window.Size = new Size(1920, 1080); Driver.Url = Environment.GetEnvironmentVariable("WebUrl") ?? "http://localhost:5000/"; messageSink.OnMessage(new DiagnosticMessage($"WebUrl = {Driver?.Url ?? "NULL"}")); Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); Driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(10); Driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(10); Driver.FindElement(By.TagName("app-root")); } catch (Exception ex) { messageSink.OnMessage(new DiagnosticMessage($"Exception while initializing driver: {ex.Message}")); Driver?.Dispose(); } }
// http://code.google.com/p/selenium/wiki/DesiredCapabilities#Proxy_JSON_Object protected FirefoxProfile getFirefoxOptions() { FirefoxProfile firefoxProfile; if (_profile != null) { if (System.IO.Directory.Exists(_profile)) { firefoxProfile = new FirefoxProfile(_profile); } else { firefoxProfile = new FirefoxProfileManager().GetProfile(_profile); if (firefoxProfile == null) { Process.Start("firefox.exe", "-CreateProfile " + _profile).WaitForExit(); } firefoxProfile = new FirefoxProfileManager().GetProfile(_profile); } } else { firefoxProfile = new FirefoxProfile(); } if (_preferences != null) { foreach (KeyValuePair <string, object> pref in _preferences) { if (pref.Value is string) { firefoxProfile.SetPreference(pref.Key, (string)pref.Value); } else if (pref.Value is short) { firefoxProfile.SetPreference(pref.Key, Convert.ToInt32(pref.Value)); } else if (pref.Value is bool) { firefoxProfile.SetPreference(pref.Key, (bool)pref.Value); } } } if (_extensions != null) { foreach (string ext in _extensions) { firefoxProfile.AddExtension(ext); } } if (_proxy != null) { firefoxProfile.SetProxyPreferences(_proxy); } firefoxProfile.EnableNativeEvents = false; firefoxProfile.AcceptUntrustedCertificates = true; firefoxProfile.Port = 9055; return(firefoxProfile); }
private static void IntializeDriver(Settings settings) { FirefoxProfile profile = new FirefoxProfileManager().GetProfile(settings.FireFoxProfileName); FirefoxOptions options = new FirefoxOptions(); options.Profile = profile; options.AddArgument("-headless"); driver = new FirefoxDriver(settings.DriverPath, options); }
private static FirefoxProfile GetFirefoxProfile() { FirefoxProfile profile = new FirefoxProfile(); FirefoxProfileManager manager = new FirefoxProfileManager(); //profile = manager.GetProfile("default"); Logger.Info(" Using Firefox Profile "); return(profile); }
//public BaseClass(string browser) //{ // browser = ConfigReader.GetBrowser; //} public static FirefoxProfile GetFirefoxptions() { FirefoxProfile profile = new FirefoxProfile(); FirefoxProfileManager manager = new FirefoxProfileManager(); profile = manager.GetProfile("default"); // Logger.Info(" Using Firefox Profile "); return(profile); }
private static void Main(string[] args) { // creates a session that uses my Firefox profile. FirefoxProfileManager profileManager = new FirefoxProfileManager(); FirefoxProfile profile = profileManager.GetProfile("Ryan"); IWebDriver driver = new FirefoxDriver(profile); driver.Url = "http://www.google.com"; var searchBox = driver.FindElement(By.Id("lst-ib")); //Looks for the correct site. searchBox.SendKeys("animefreak.tv"); searchBox.Submit(); var searchButton = driver.FindElement(By.ClassName("lsb")); searchButton.Click(); System.Threading.Thread.Sleep(1000); // Click on the first result for AnimeFreak.tv driver.FindElement(By.XPath("id('rso')/div/div[1]/div/h3/a")).Click(); System.Threading.Thread.Sleep(1000); driver.FindElement(By.XPath("id('submenu')/ul/li[3]/a")).Click(); System.Threading.Thread.Sleep(1000); //Selects "O" from the list driver.FindElement(By.XPath("id('primary')/div/div[3]/div[1]/div/div/span[20]/a")).Click(); System.Threading.Thread.Sleep(1000); //Goes to OnePiece driver.FindElement(By.XPath(".//*[@id='primary']/div/div[3]/div[2]/table/tbody/tr[9]/td/a")).Click(); System.Threading.Thread.Sleep(1000); //Goes to Episode 422 //driver.FindElement(By.XPath("id('page')/div[5]/div[2]/div[2]/div/ul/li[418]/a")).Click(); driver.FindElement(By.XPath("id('page')/div[5]/div[2]/div[2]/div/ul/li[1]/a")).Click(); System.Threading.Thread.Sleep(1000); do { if (!driver.FindElement(By.XPath("id('primary')/div/div[3]/div/a[2]")).Enabled) { } driver.FindElement(By.ClassName("page-next")).Click(); } while (driver.FindElement(By.XPath("id('primary')/div/div[3]/div/a[2]")).Enabled); driver.Close(); }
public static IWebDriver SetUpFirefoxDriver() { //FIREFOX with lame untrusted certificate exception workaround FirefoxProfileManager ffprofmanager = new FirefoxProfileManager(); FirefoxProfile firefoxProfile = ffprofmanager.GetProfile(firefoxProfileName); firefoxProfile.AcceptUntrustedCertificates = true; firefoxProfile.AssumeUntrustedCertificateIssuer = false; return(new FirefoxDriver(firefoxProfile)); }
public static FirefoxDriver CreateFirefoxDriverWithDefaultProfile() { var profileManager = new FirefoxProfileManager(); FirefoxProfile profile = profileManager.GetProfile("default"); FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.Profile = profile; var firefoxDriver = new FirefoxDriver(firefoxOptions); return(firefoxDriver); }
private static FirefoxProfile GetFirefoxProfile() { FirefoxProfile profile = new FirefoxProfile(); FirefoxProfileManager manager = new FirefoxProfileManager(); profile.SetPreference("webdriver.gecko.driver", @"C:\Users\ramon\Downloads\geckodriver.exe"); profile = manager.GetProfile("default"); return(profile); }
public static FirefoxProfile CookieProfiles(string cookieProfile) { var profile = new FirefoxProfile(); if (cookieProfile != string.Empty) { var myProfile = new FirefoxProfileManager(); profile = myProfile.GetProfile(cookieProfile); } return(profile); }
public static FirefoxOptions GetOptions() { FirefoxProfileManager manager = new FirefoxProfileManager(); FirefoxOptions options = new FirefoxOptions() { Profile = manager.GetProfile("default"), AcceptInsecureCertificates = true, }; return(options); }
public static void Start(TestContext context) { FirefoxProfileManager profileManager = new FirefoxProfileManager(); FirefoxProfile profile = profileManager.GetProfile("profileToolsQA"); WebDriver = new FirefoxDriver(profile); TestUserName = "******"; TestUserPassword = "******"; //TestApplicationBaseUrl = @"https://*****:*****@"C:\Temp\Powerfront\"; }
private static FirefoxOptions SetOptions(Dictionary <string, object> capabilities) { var options = new FirefoxOptions(); var profile = new FirefoxProfile(); foreach (var cap in capabilities) { if (cap.Key.Equals("FirefoxProfile", StringComparison.OrdinalIgnoreCase)) { profile = new FirefoxProfileManager().GetProfile(cap.Value.ToString()); } else if (cap.Key.StartsWith("Capability", StringComparison.OrdinalIgnoreCase)) { var args = Extensions.ParseWithDelimiter(cap.Value.ToString()); options.AddAdditionalCapability(args[0], args[1]); } else if (cap.Key.Equals("Binary", StringComparison.OrdinalIgnoreCase)) { options.BrowserExecutableLocation = cap.Value.ToString(); } else if (cap.Key.Equals("Arguments", StringComparison.OrdinalIgnoreCase)) { options.AddArguments(cap.Value.ToString().Split(';')); } else if (cap.Key.StartsWith("Preference", StringComparison.OrdinalIgnoreCase)) { var args = Extensions.ParseWithDelimiter(cap.Value.ToString()); options.SetPreference(args[0], args[1]); } else if (cap.Key.Equals("Extensions", StringComparison.OrdinalIgnoreCase)) { foreach (var extension in cap.Value.ToString().Split(';')) { profile.AddExtension(extension); } } else if (cap.Key.Equals("AcceptUntrustedCertificates", StringComparison.OrdinalIgnoreCase)) { profile.AcceptUntrustedCertificates = true; } else if (cap.Key.Equals("AcceptInsecureCertificates", StringComparison.OrdinalIgnoreCase)) { options.AcceptInsecureCertificates = true; } else if (cap.Key.Equals("AssumeUntrustedCertificateIssuer", StringComparison.OrdinalIgnoreCase)) { profile.AssumeUntrustedCertificateIssuer = true; } } options.Profile = profile; return(options); }
private void OpenBrowser(object sender, DoWorkEventArgs e) { var manager = new FirefoxProfileManager(); var ffProfile = manager.GetProfile("default"); var fds = FirefoxDriverService.CreateDefaultService(MainWindow.panelOptions.FirefoxDriverPath); fds.HideCommandPromptWindow = true; var options = new FirefoxOptions(); options.Profile = ffProfile; chrome = new FirefoxDriver(fds, options, new TimeSpan(0, 2, 0)); wait = new WebDriverWait(chrome, new TimeSpan(0, 0, 5)); }
public void ShouldBeAbleToStartANamedProfile() { FirefoxProfile profile = new FirefoxProfileManager().GetProfile("default"); if (profile != null) { IWebDriver firefox = new FirefoxDriver(profile); firefox.Quit(); } else { Assert.Ignore("Skipping test: No profile named \"default\" found."); } }
public void SetUp() { manager = new FirefoxProfileManager(); }