Exemplo n.º 1
0
        private IWebDriver GetFirefoxWithCapabilities()
        {
            var capabilities = new FirefoxOptions();

            capabilities.AddAdditionalCapability(CapabilityType.Version, "latest", true);
            capabilities.AddAdditionalCapability(CapabilityType.Platform, "WIN10", true);
            capabilities.AddAdditionalCapability("name", TestContext.CurrentContext.Test.Name, true);
            capabilities.AddAdditionalCapability("screenshot", true, true);
            capabilities.AddAdditionalCapability("screen-resolution", "1920x1080", true);
            capabilities.AddAdditionalCapability("maxduration", "900", true);
            capabilities.AddAdditionalCapability("key", "40b8966a5560cc990cf5db5abca012fd", true);
            capabilities.AddAdditionalCapability("secret", "50b5af130420f08f89662efa10919a23", true);

            var driver = new RemoteWebDriver(new Uri("http://hub.testingbot.com/wd/hub"), capabilities.ToCapabilities(),
                                             TimeSpan.FromSeconds(1000));

            Console.WriteLine("TestingBotSessionID=" + ((RemoteWebDriver)driver).SessionId.ToString());
            return(driver);
        }
Exemplo n.º 2
0
        static FirefoxDriver TryCreateDriverWithProxy()
        {
            var result         = default(FirefoxDriver);
            var proxyIsFounded = false;

            DCT.Execute(d =>
            {
                if (currentProxy == null)
                {
                    CheckProxy();
                }
                if (currentProxy != null)
                {
                    Console.WriteLine($"PROXY {currentProxy.Address}:{currentProxy.Port} --- PING:{currentProxy.PingLast}");
                    var options     = new FirefoxOptions();
                    var proxy       = new Proxy();
                    proxy.HttpProxy = $"{currentProxy.Address}:{currentProxy.Port}";
                    proxy.FtpProxy  = $"{currentProxy.Address}:{currentProxy.Port}";
                    proxy.SslProxy  = $"{currentProxy.Address}:{currentProxy.Port}";
                    options.Proxy   = proxy;
                    options.SetPreference("permissions.default.image", 2);
                    options.SetPreference("dom.ipc.plugins.enabled.libflashplayer.so", false);

                    var tempDriver = new FirefoxDriver(options);
                    tempDriver.Navigate().GoToUrl("https://www.avito.ru");

                    if (!(tempDriver.Title.Contains("Доступ с вашего IP-адреса временно ограничен") &&
                          tempDriver.Title.Contains("Доступ временно заблокирован")))
                    {
                        proxyIsFounded = true;
                        result         = tempDriver;
                        UpdateActions(result);
                    }
                }
            });
            if (!proxyIsFounded)
            {
                CloseDriver();
                TryCreateDriverWithProxy();
            }
            return(result);
        }
        private static ITestWebDriver CreateFirefoxDriver(TestSettings testSettings, int browserVersion, bool isStandalone)
        {
            testSettings.BrowserName = "Firefox " + browserVersion;

            string driverLocation = GetMultiBrowserDriverBasePath();

            driverLocation = Path.Combine(driverLocation, "FirefoxDrivers", browserVersion.ToString());

            var driverService = FirefoxDriverService.CreateDefaultService(driverLocation);

            var options = new FirefoxOptions();

            if (isStandalone)
            {
                options.BrowserExecutableLocation = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData) + "\\MultiBrowser\\MB_Firefox" + browserVersion + ".exe";
            }

            options.UseLegacyImplementation = false;

            var driver = new FirefoxDriver(driverService, options, testSettings.TimeoutTimeSpan);

            if (testSettings.DeleteAllCookies)
            {
                driver.Manage().Cookies.DeleteAllCookies();
            }

            if (browserVersion > 50)
            {
                driver.Manage().Timeouts().ImplicitWait = testSettings.TimeoutTimeSpan;
            }

            if (testSettings.MaximiseBrowser)
            {
                driver.Manage().Window.Maximize();
            }

            var extendedWebDriver = new TestWebDriver(driver, testSettings, TestOutputHelper);

            TestWebDriver = extendedWebDriver;

            return(extendedWebDriver);
        }
Exemplo n.º 4
0
        private void Init()
        {
            FirefoxOptions options       = new FirefoxOptions();
            var            driverService = FirefoxDriverService.CreateDefaultService();

            driverService.HideCommandPromptWindow = true;

            //options.AddArgument("--start-maximized");
            //options.AddArgument("--auth-server-whitelist");
            //options.AddArguments("--disable-extensions");
            options.AddArgument("--ignore-certificate-errors");
            options.AddArgument("--ignore-ssl-errors");
            options.AddArgument("--system-developer-mode");
            options.AddArgument("--no-first-run");
            options.SetLoggingPreference(LogType.Driver, LogLevel.All);
            //options.AddAdditionalCapability("useAutomationExtension", false);
            //chromeOptions.AddArguments("--disk-cache-size=0");
            //options.AddArgument("--user-data-dir=" + m_chr_user_data_dir);
#if !DEBUG
            options.AddArguments("--headless");
            options.AddArguments("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.117 Safari/537.36");
            options.AddArguments("--disable-plugins-discovery");
            //options.AddArguments("--profile-directory=Default");
            //options.AddArguments("--no-sandbox");
            //options.AddArguments("--incognito");
            //options.AddArguments("--disable-gpu");
            //options.AddArguments("--no-first-run");
            //options.AddArguments("--ignore-certificate-errors");
            //options.AddArguments("--start-maximized");
            //options.AddArguments("disable-infobars");

            //options.AddAdditionalCapability("acceptInsecureCerts", true, true);
#endif
            FirefoxDriver = new FirefoxDriver(driverService, options, TimeSpan.FromSeconds(DEFAULT_TIMEOUT_PAGELOAD));
            FirefoxDriver.Manage().Window.Position = new Point(0, 0);
            FirefoxDriver.Manage().Window.Size = new Size(1200, 900);
            FirefoxDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
            JSE  = (IJavaScriptExecutor)FirefoxDriver;
            Wait = new WebDriverWait(FirefoxDriver, TimeSpan.FromSeconds(180));
            Wait.IgnoreExceptionTypes(typeof(StaleElementReferenceException));
            Wait.IgnoreExceptionTypes(typeof(NoSuchElementException));
        }
Exemplo n.º 5
0
        static void Main(string[] args)
        {
            // driver init
            FirefoxBinary  binary  = new FirefoxBinary();
            FirefoxOptions options = new FirefoxOptions();//optional

            options.BrowserExecutableLocation = @"C:\Program Files\Mozilla Firefox\firefox.exe";
            IWebDriver driver;

            //data
            string knockToolUrl = @"https://knockrentals.github.io/doorway-v3/";

            using (driver = new FirefoxDriver(@"C:\bin", options))
            {
                driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(15);

                driver.Navigate().GoToUrl(knockToolUrl);

                try{
                    // Test
                    Doorway_Page doorwayPage = new Doorway_Page(driver);
                    doorwayPage.click_schedule_a_tour();

                    Schedule_Page schedulePage = new Schedule_Page(driver);
                    schedulePage.enter_frame();
                    // schedulePage.choose_time("10:30 am");
                    schedulePage.fill_first_name("John");
                    schedulePage.fill_last_name("Koropchak");
                    schedulePage.fill_email("*****@*****.**");
                    schedulePage.fill_phone("2068908289x");
                    schedulePage.click_book_button();

                    // verify booking was scheduled
                    driver.FindElement(By.XPath("//button[.='Reschedule']")).Click();
                    schedulePage.exit_frame();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
            }
        }
Exemplo n.º 6
0
        public IWebDriver CreateDriver(Browser browser, bool headless)
        {
            switch (browser)
            {
            case Browser.Chrome:
                var optionsChrome = new ChromeOptions();

                if (headless)
                {
                    optionsChrome.AddArgument("--headless");
                }

                optionsChrome.AddArguments(
                    "--disable-web-security",
                    "-allow-running-insecure-content",
                    "--disable-gpu",
                    "--window-size=1920x1080",
                    "--no-sandbox");

                //return new ChromeDriver(Path.GetFullPath("./"), optionsChrome, TimeSpan.FromMinutes(3));
                return(new ChromeDriver(Path.GetFullPath("./")));

            case Browser.Firefox:
                var optionsFirefox = new FirefoxOptions();

                if (headless)
                {
                    optionsFirefox.AddArgument("--headless");
                }

                optionsFirefox.AddArguments(
                    "--disable-web-security",
                    "-allow-running-insecure-content",
                    "--disable-gpu",
                    "--window-size=1920x1080",
                    "--no-sandbox");

                return(new FirefoxDriver(Path.GetFullPath("./"), optionsFirefox, TimeSpan.FromMinutes(3)));
            }

            return(default(IWebDriver));
        }
Exemplo n.º 7
0
        public static IWebDriver Init()
        {
            string     browserName = AppConfig.Instance.BrowserName;
            IWebDriver instance;

            switch (browserName)
            {
            case "Chrome":
                ChromeOptions choptions = new ChromeOptions();
                instance = new ChromeDriver(choptions);
                break;

            case "FireFox":
                FirefoxOptions ffOptions = new FirefoxOptions();
                ffOptions.Profile = InitFirefoxProfile();
                ffOptions.BrowserExecutableLocation = "C:\\Program Files\\Mozilla Firefox\\firefox.exe";
                ffOptions.UseLegacyImplementation   = true;
                instance = new FirefoxDriver(ffOptions);
                break;

            case "Internet Explorer":
                instance = new InternetExplorerDriver(InitIeOptions());
                break;

            case "Microsoft Edge":
                EdgeOptions edgeOptions = new EdgeOptions();
                instance = new EdgeDriver(edgeOptions);
                break;

            default:
                instance = new ChromeDriver();
                break;
            }

            instance.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
            try
            {
                instance.Manage().Window.Maximize();
            }
            catch (NoSuchElementException) { }
            return(instance);
        }
Exemplo n.º 8
0
        public void BeforeScenario()
        {
            string BrowserName = ConfigurationManager.AppSettings["BrowserName"];
            string URL         = ConfigurationManager.AppSettings["URL"];

            Console.WriteLine(BrowserName);
            Console.WriteLine(URL);
            if (BrowserName.ToLower() == "chrome")
            {
                GeneralMethods.driver = new ChromeDriver(@"C:\BuildAgent\work\7208447af8b97fa0\AKANewMedia\Drivers");
                GeneralMethods.driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(100);
                GeneralMethods.driver.Navigate().GoToUrl(URL);
                GeneralMethods.driver.Manage().Window.Maximize();
            }
            else if (BrowserName.ToLower() == "ie")
            {
                var options = new InternetExplorerOptions();


                options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
                GeneralMethods.driver = new InternetExplorerDriver(options);
                GeneralMethods.driver = new InternetExplorerDriver(@"C:\BuildAgent\work\7208447af8b97fa0\AKANewMedia\Drivers");
                GeneralMethods.driver.Navigate().GoToUrl(URL);
                System.Threading.Thread.Sleep(100);
                GeneralMethods.driver.Manage().Window.Maximize();
            }
            else if (BrowserName.ToLower() == "firefox")
            {
                FirefoxProfileManager Manager = new FirefoxProfileManager();

                FirefoxProfile profile = Manager.GetProfile("Default");

                FirefoxDriverService Service = FirefoxDriverService.CreateDefaultService(@"C:\BuildAgent\work\7208447af8b97fa0\AKANewMedia\Drivers");

                FirefoxOptions options = new FirefoxOptions();
                options.Profile = profile;

                IWebDriver objFirefox = new FirefoxDriver(Service, options, TimeSpan.FromSeconds(60));

                objFirefox.Navigate().GoToUrl(URL);
            }
        }
        protected static void InitWebDriver()
        {
            Console.WriteLine("InitWebDriver");

            string browser        = ConfigurationSettings.AppSettings["Browser"];
            string browserOption1 = ConfigurationSettings.AppSettings["BrowserOption1"];

            browser = browser.ToLower();
            switch (browser)
            {
            case "chrome":
                var chromeOptions = new ChromeOptions();
                if (!browserOption1.Equals(""))
                {
                    chromeOptions.AddArguments(browserOption1);
                }
                _driver = new ChromeDriver(chromeOptions);
                break;

            case "firefox":
                var firefoxOptions = new FirefoxOptions();
                if (!browserOption1.Equals(""))
                {
                    firefoxOptions.AddArguments(browserOption1);
                }
                _driver = new FirefoxDriver(firefoxOptions);
                break;

            default:
                firefoxOptions = new FirefoxOptions();
                //firefoxOptions.AddArguments("--headless");
                _driver = new FirefoxDriver(firefoxOptions);
                break;
            }


            _driver.Manage().Cookies.DeleteAllCookies();
            _driver.Manage().Window.Maximize();
            _driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(30);
            _driver.Manage().Timeouts().AsynchronousJavaScript = TimeSpan.FromSeconds(30);
            _driver.Manage().Timeouts().ImplicitWait           = TimeSpan.FromSeconds(30);
        }
Exemplo n.º 10
0
        public static void Main(String[] args)
        {
            ChromeOptions opt;

            opt.AddArgument;

            InternetExplorerOptions opt;

            opt.AddArgument



            FirefoxOptions opt = new FirefoxOptions();

            opt.AddArgument("--headless");

            IWebDriver driver = new FirefoxDriver(opt);

            driver.Url = "https://www.linkedin.com/login?fromSignIn=true&trk=guest_homepage-basic_nav-header-signin";

            IWebElement userID;

            userID = driver.FindElement(By.Id("username"));

            Console.WriteLine("Height " + userID.GetCssValue("height"));
            Console.WriteLine("Property " + userID.GetProperty("name"));
            Console.WriteLine("Attribute " + userID.GetAttribute("tag"));
            Console.WriteLine("Sixe " + userID.Size);
            Console.WriteLine("Position " + userID.Location);

            Console.WriteLine("Enabled??? " + userID.Enabled);
            Console.WriteLine("Displayed?? " + userID.Displayed);
            Console.WriteLine("Selected ?? " + userID.Selected);

            userID.Click();
            Thread.Sleep(2);
            userID.SendKeys("*****@*****.**");
            Thread.Sleep(2);
            userID.Clear();

            driver.FindElement(By.ClassName("btn__primary--large")).Submit();
        }
Exemplo n.º 11
0
        /// <summary>
        /// Determines what driver to create based on browser type
        /// </summary>
        /// <param name="type"></param>
        /// <param name="timeOutSec"></param>
        /// <returns>Driver</returns>
        public static IWebDriver GetDriver(BrowserType type, int timeOutSec)
        {
            IWebDriver driver = null;

            switch (type)
            {
                case BrowserType.Chrome:
                    {
                        var service = ChromeDriverService.CreateDefaultService();
                        var option = new ChromeOptions();
                        option.AddArgument("disable-infobars");
                        driver = new ChromeDriver(service, option, TimeSpan.FromSeconds(timeOutSec));
                        break;
                    }

                case BrowserType.Firefox:
                    {
                        var service = FirefoxDriverService.CreateDefaultService();
                        var options = new FirefoxOptions();
                        driver = new FirefoxDriver(service, options, TimeSpan.FromSeconds(timeOutSec));
                        break;
                    }

                case BrowserType.remoteFirefox:
                    {
                        var option = new FirefoxOptions();
                        driver = new RemoteWebDriver(new Uri("http://localhost:5566/wd/hub"), option.ToCapabilities());
                        break;
                    }

                case BrowserType.remoteChrome:
                    {
                        var option = new ChromeOptions();
                        option.AddArgument("disable-infobars");
                        option.AddArgument("--no-sandbox");
                        driver = new RemoteWebDriver(new Uri("http://localhost:5566/wd/hub"), option.ToCapabilities());
                        break;
                    }
            }

            return driver;
        }
Exemplo n.º 12
0
 public void getHtml()
 {
     try
     {
         var ffService = FirefoxDriverService.CreateDefaultService(Directory.GetCurrentDirectory(), "geckodriver.exe");
         ffService.HideCommandPromptWindow = true;
         FirefoxOptions ffOptions = new FirefoxOptions();
         _driver = new FirefoxDriver(ffService, ffOptions, TimeSpan.FromSeconds(6));
         _driver.Navigate().GoToUrl(txUrl.Text.Trim());
         textHtml.Text = _driver.PageSource;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
     finally
     {
         _driver.Quit();
     }
 }
Exemplo n.º 13
0
        // Protected members

        protected override IWebDriver GetWebDriver(IWebBrowserInfo webBrowserInfo, IWebDriverOptions webDriverOptions)
        {
            string webDriverDirectoryPath = Path.GetDirectoryName(webDriverOptions.WebDriverExecutablePath);

            FirefoxDriverService driverService = FirefoxDriverService.CreateDefaultService(webDriverDirectoryPath);

            ConfigureDriverService(driverService);

            FirefoxOptions driverOptions = new FirefoxOptions {
                BrowserExecutableLocation = webBrowserInfo.ExecutablePath
            };

            ConfigureDriverOptions(driverOptions, webDriverOptions);

            FirefoxDriver driver = new FirefoxDriver(driverService, driverOptions);

            ConfigureDriver(driver, webDriverOptions);

            return(driver);
        }
Exemplo n.º 14
0
        public static string FirefowTest(string url)
        {
            var firefoxdeiverservices = FirefoxDriverService.CreateDefaultService();

            firefoxdeiverservices.HideCommandPromptWindow = true;
            var            time3    = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
            FirefoxOptions foptions = new FirefoxOptions();

            foptions.AddArguments("--headless");
            var driverFirefox = new FirefoxDriver(firefoxdeiverservices, foptions);

            driverFirefox.Navigate().GoToUrl(url);

            driverFirefox.Quit();
            var time4 = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;

            var result = (time4 - time3).ToString();

            return(result);
        }
Exemplo n.º 15
0
        internal override void StartDriver(Proxy mProxy)
        {
            FirefoxOptions FirefoxOption = new FirefoxOptions();

            FirefoxOption.Proxy = mProxy;
            FirefoxOption.AcceptInsecureCertificates = true;
            if (HeadlessBrowserMode)
            {
                FirefoxOption.AddArgument("--headless");
            }
            if (!string.IsNullOrEmpty(UserProfileFolderPath) && System.IO.Directory.Exists(UserProfileFolderPath))
            {
                FirefoxProfile ffProfile2 = new FirefoxProfile();
                ffProfile2 = new FirefoxProfile(UserProfileFolderPath);

                FirefoxOption.Profile = ffProfile2;
            }

            Driver = new FirefoxDriver(SeleniumServiceBase.GetDriverPath("FireFox"), FirefoxOption, TimeSpan.FromSeconds(Convert.ToInt32(HttpServerTimeOut)));
        }
        private IWebDriver GetFireFoxDriver()
        {
            FirefoxOptions options = new FirefoxOptions();
            string         Path    = System.Environment.GetEnvironmentVariable("USERPROFILE") + "\\Downloads";

            options.SetPreference("browser.download.folderList", 2);
            options.SetPreference("browser.download.dir", Path);
            options.SetPreference("browser.download.manager.alertOnEXEOpen", false);
            options.SetPreference("browser.helperApps.neverAsk.saveToDisk", "application/msword, application/csv, application/ris, text/csv, text/xlsx, image/png, application/pdf, text/html, text/plain, application/zip, application/x-zip, application/x-zip-compressed, application/download, application/octet-stream");
            options.SetPreference("browser.download.manager.showWhenStarting", false);
            options.SetPreference("browser.download.manager.focusWhenStarting", false);
            options.SetPreference("browser.download.useDownloadDir", true);
            options.SetPreference("browser.helperApps.alwaysAsk.force", false);
            options.SetPreference("browser.download.manager.alertOnEXEOpen", false);
            options.SetPreference("browser.download.manager.closeWhenDone", true);
            options.SetPreference("browser.download.manager.showAlertOnComplete", false);
            options.SetPreference("browser.download.manager.useWindow", false);
            options.SetPreference("services.sync.prefs.sync.browser.download.manager.showWhenStarting", false);
            return(new FirefoxDriver(GetDriverPath(), options));
        }
Exemplo n.º 17
0
        public void TestCase2()
        {
            Console.WriteLine("GoGo test 2");
            FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(@"D:\Wirtek work\Automation\Curs Automation 2018 - Gabriel Carabat\GIT\csharp_automation\Homeworks\Cristian Olariu\Lectia3\Lectia3\Lectia3");
            FirefoxOptions       options = new FirefoxOptions();
            IWebDriver           driver  = new FirefoxDriver(service, options, TimeSpan.FromMinutes(1));

            driver.Navigate().GoToUrl("https://www.seleniumeasy.com/test/basic-first-form-demo.html");
            Task.Delay(2000).Wait();
            Console.WriteLine("The page title is: " + driver.Title);
            Assert.AreEqual("Selenium Easy Demo - Simple Form to Automate using Selenium", driver.Title);
            driver.FindElement(By.Id("sum1")).SendKeys("2");
            driver.FindElement(By.Id("sum2")).SendKeys("2");
            driver.FindElement(By.XPath("//button[contains(.,'Get Total')]")).Click();
            string actualvalue = driver.FindElement(By.Id("displayvalue")).Text;

            Assert.IsTrue(actualvalue.Contains("4"), actualvalue + " doesn't contains '4'");
            Task.Delay(2000).Wait();
            driver.Quit();
        }
Exemplo n.º 18
0
        private void button1_Click(object sender, EventArgs e)
        {
            String  torBinaryPath = @"D:\Tor\Tor Browser\Browser\firefox.exe";
            Process TorProcess    = new Process();

            TorProcess.StartInfo.FileName    = torBinaryPath;
            TorProcess.StartInfo.Arguments   = "-n";
            TorProcess.StartInfo.WindowStyle = ProcessWindowStyle.Maximized;
            TorProcess.Start();
            FirefoxOptions options = new FirefoxOptions();

            options.SetPreference("network.proxy.type", 1);
            options.SetPreference("network.proxy.socks", "127.0.0.1");
            options.SetPreference("network.proxy.socks_port", 9150);
            options.SetPreference("webdriver.firefox.profile", "default");
            FirefoxDriver _Driver = new FirefoxDriver(options);

            _Driver.Navigate().GoToUrl("https://member.lazada.vn/user/login");
            m_LoginGoogle.Click();
        }
Exemplo n.º 19
0
        private ApplicationManager()
        {
            FirefoxOptions options = new FirefoxOptions();

            options.UseLegacyImplementation   = true;
            options.BrowserExecutableLocation = @"C:\Program Files\Mozilla Firefox\firefox.exe";

            driver       = new FirefoxDriver(options);
            baseURL      = "http://localhost/mantisbt-1.2.20";
            Registration = new RegistrationHelper(this);
            Login        = new LoginHelper(this);
            Ftp          = new FtpHelper(this);
            James        = new JamesHelper(this);
            Mail         = new MailHelper(this);
            Menu         = new ManagementMenuHelper(this);
            Project      = new ProjectManagementHelper(this);
            Admin        = new AdminHelper(this, baseURL);
            API          = new APIHelper(this);
            //          verificationErrors = new StringBuilder();
        }
Exemplo n.º 20
0
        public void LoadPage(string url, bool headless = true)
        {
            this.url = url;
            FirefoxOptions options = new FirefoxOptions();

            if (headless)
            {
                options.AddArgument("--headless");
            }
            browser = new FirefoxDriver(options);
            browser.Navigate().GoToUrl(url);
            if (windowSize.Height == 0 && windowSize.Width == 0)
            {
                windowSize = browser.Manage().Window.Size;
            }
            else
            {
                browser.Manage().Window.Size = windowSize;
            }
        }
Exemplo n.º 21
0
        public RemoteWebDriver GetDriver(string type)
        {
            RemoteWebDriver driver = null;

            switch (type)
            {
            case "chrome":
                ChromeOptions options = new ChromeOptions();
                options.AddArgument("--start-maximized");
                driver = new ChromeDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), options);
                break;

            case "firefox":
                FirefoxOptions firefoxOptions = new FirefoxOptions();
                firefoxOptions.AddArgument("--start-maximized");
                driver = new FirefoxDriver(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), firefoxOptions);
                break;
            }
            return(driver);
        }
        private ApplicationManager()
        {
            FirefoxOptions options = new FirefoxOptions();

            options.BrowserExecutableLocation = @"c:\Program Files\Mozilla Firefox\firefox.exe";
            options.UseLegacyImplementation   = true;
            driver  = new FirefoxDriver(options);
            baseURL = "http://localhost/mantisbt-2.16.0";

            Auth = new LoginHelper(this, baseURL);
            ProjectsAdministration = new ProjectManagementHelper(this);
            AdminNavigator         = new AdminHelper(this);
            UserNavigator          = new UserNavigation(this, baseURL);
            API = new APIHelper(this);

            Registration = new RegUserHelper(this);
            Ftp          = new FtpHelper(this);
            MailServer   = new JamesHelper(this);
            Mail         = new MailHelper(this);
        }
Exemplo n.º 23
0
        public static void MusicOn()
        {
            FirefoxOptions options = new FirefoxOptions();

            options.AddArguments("--headless");  //запуск в фоновом режиме
            Browser = new FirefoxDriver(options);
            // Browser.Manage().Window.Minimize(); свернуть в трей
            Console.WriteLine("Включаю");
            Browser.Navigate().GoToUrl("https://vk.com/audios59553956");
            IWebElement SearchInput = Browser.FindElement(By.Id("email"));

            SearchInput.SendKeys("login");                                       //login here
            SearchInput = Browser.FindElement(By.Id("pass"));
            SearchInput.SendKeys("password" + OpenQA.Selenium.Keys.Enter);       //pass here
            Browser.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10); //Ожидать загрузки страницы
            SearchInput = Browser.FindElement(By.CssSelector("button[class='audio_page__shuffle_all_button']"));
            SearchInput.Click();

            RecognizeMusicCommands();
        }
        public IWebDriver CreateWebDriver()
        {
            FirefoxOptions options = new FirefoxOptions
            {
                AcceptInsecureCertificates = true
            };
            IWebDriver webDriver     = null;
            bool       isRemotDriver = false;

            //Pick value from config file
            if (!isRemotDriver)                                        //Boolean.parseBoolean(XiomateConfiguration.getInstance().getValue("xiomate.test.remote"))
            {
                webDriver = LaunchGridDriver(options, new Uri("uri")); //XiomateConfiguration.getInstance().getValue("xiomate.test.grid.url"
            }
            else
            {
                webDriver = new FirefoxDriver(options);
            }
            return(webDriver);
        }
Exemplo n.º 25
0
        public override RemoteWebDriver InitialiseForSauceLabs()
        {
            var options = new FirefoxOptions {
                PlatformName = MacPlatform, BrowserVersion = BrowserVersion, AcceptInsecureCertificates = true
            };

            if (LoggingEnabled)
            {
                SauceOptions.Add("extendedDebugging", true);
                options.SetPreference("devtools.chrome.enabled", true);
                options.SetPreference("devtools.debugger.prompt-connection", false);
                options.SetPreference("devtools.debugger.remote-enabled", true);
            }

            options.SetPreference("media.navigator.streams.fake", true);
            options.SetPreference("media.navigator.permission.disabled", true);
            options.SetPreference("media.autoplay.default", 0);
            options.AddAdditionalCapability("sauce:options", SauceOptions, true);
            return(new RemoteWebDriver(Uri, options));
        }
Exemplo n.º 26
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            firefoxDriverService = FirefoxDriverService.CreateDefaultService();
            firefoxDriverService.HideCommandPromptWindow = true;

            firefoxOptions = new FirefoxOptions();
            firefoxOptions.AddArgument("--window-position=-32000,-32000");

            firefoxDriver = new FirefoxDriver(firefoxDriverService, firefoxOptions);
            firefoxDriver.Manage().Window.Minimize();
            firefoxDriver.Url = "https://google.com";
            firefoxDriver.Navigate();

            Thread.Sleep(200);
            searchBar = firefoxDriver.FindElementByCssSelector("input[type=\'text\']");
            while (searchBar is null)
            {
                searchBar = firefoxDriver.FindElementByCssSelector("input[type=\'text\']");
            }
        }
Exemplo n.º 27
0
        public static IWebDriver BuildFirefox(bool showScraper = true, int timeOut = 10)
        {
            // I'm assuming your geckodriver.exe is located there:
            // @"C:\MyGeckoDriverExePath\geckodriver.exe"
            FirefoxDriverService service = FirefoxDriverService.CreateDefaultService(System.IO.Directory.GetCurrentDirectory());

            service.FirefoxBinaryPath       = @"C:\Program Files\Mozilla Firefox\firefox.exe"; // May not be necessary
            service.HideCommandPromptWindow = true;
            FirefoxOptions options = new FirefoxOptions()
            {
            };

            if (showScraper == false)
            {
                options.AddArgument("--headless");
            }
            var driver = new FirefoxDriver(service, options, TimeSpan.FromSeconds(timeOut));

            return(driver);
        }
        private static IWebDriver CreateFirefoxDriver()
        {
            try
            {
                var            driver  = $@"{Environment.CurrentDirectory}/Libs/GeckoDriver";
                var            service = FirefoxDriverService.CreateDefaultService(driver);
                FirefoxOptions options = new FirefoxOptions();
                //TimeSpan time = TimeSpan.FromSeconds(20);

                //options.AddArgument("--headless");
                service.FirefoxBinaryPath = @"C:\Program Files\Mozilla Firefox\firefox.exe"; // May not be necessary

                return(new FirefoxDriver(service, options));                                 //, time);
            }
            catch (Exception e)
            {
                Console.WriteLine("{0} Exception caught.", e);
                throw new NotSupportedException("Error in CreateFirefoxDriver", e);
            }
        }
        public void web_content_key_extraction(string key_contents)
        {
            /*
             * EdgeOptions edgeOptions = new EdgeOptions();
             * var current_drver = new EdgeDriver();
             * OpenQA.Selenium.IWebDriver current_drver = new Microsoft.EdgeDriver();
             * var options = new EdgeOptions();
             * options.UseInPrivateBrowsing = true;
             * var current_driver = new EdgeDriver(options);
             */

            try
            {
                Console.WriteLine("[=] Attempting to run Chrome Driver");
                // https://stackoverflow.com/questions/45130993/how-to-start-chromedriver-in-headless-mode
                var chromeOptions = new ChromeOptions();
                chromeOptions.AddArguments("headless");
                OpenQA.Selenium.IWebDriver current_driver = new OpenQA.Selenium.Chrome.ChromeDriver(chromeOptions);
                current_driver.Navigate().GoToUrl(@"https://anthony-t-n.github.io/");
                current_driver.FindElement(By.Name("message")).SendKeys(key_contents);
                current_driver.FindElement(By.Name("send")).Click();
                current_driver.Quit();
            }
            catch (Exception e)
            {
                Console.WriteLine("[=] Attempting to try FireFox Driver");
                Console.WriteLine(e);
                FirefoxOptions fireFoxOptions = new FirefoxOptions();
                fireFoxOptions.AddArgument("--headless");
                OpenQA.Selenium.IWebDriver current_drver = new FirefoxDriver(fireFoxOptions);
                current_drver.Navigate().GoToUrl(@"https://anthony-t-n.github.io/");
                current_drver.FindElement(OpenQA.Selenium.By.Name("message")).SendKeys(key_contents);
                current_drver.FindElement(OpenQA.Selenium.By.Name("send")).Click();
                current_drver.Quit();
            }
            finally
            {
                Console.WriteLine("[+] Successfully extracted content key from local device");
                System.Threading.Thread.Sleep(1000);
            }
        }
Exemplo n.º 30
0
        private MethodResult homeTest()
        {
            var options = new FirefoxOptions();

            if (isHeadless)
            {
                options.AddArgument("headless");
            }
            var driver = new FirefoxDriver(options);

            var naviger = new SociatisNaviger(driver, "test2", "abc", "http://soctest.sociatis.net");

            DateTime now = DateTime.Now;

            try
            {
                while (true)
                {
                    naviger.GotoHome();
                    var bodyText = driver.FindElement(By.TagName("body")).Text;
                    Assert.DoesNotContain(("Store update, insert, or delete statement"), bodyText);

                    if ((DateTime.Now - now).Seconds > 25)
                    {
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                lock (ConcurrentHomeTestsResults)
                    ConcurrentHomeTestsResults.AddError(e.Message);
                return(new MethodResult(e.Message));
            }
            finally
            {
                driver.Close();
            }

            return(MethodResult.Success);
        }