コード例 #1
0
        public void TestSafari()
        {
            IWebDriver driver = null;

            try
            {
                SafariOptions options = new SafariOptions();

                driver     = new SafariDriver();
                driver.Url = "http://www.softpost.org";
                driver.Manage().Window.Maximize();
                driver.Navigate();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception ....*********" + e.ToString());
            }

            finally
            {
                Thread.Sleep(2000);
                driver.Close();
                driver.Quit();
            }
        }
コード例 #2
0
        public void WrongChar()
        {
            //For Mac Inıtialize the Safari Driver
            SafariDriver safariDriver = new SafariDriver();

            // Maximize the browser
            safariDriver.Manage().Window.Maximize();

            // Go to the "Lolaflora" login page
            safariDriver.Navigate().GoToUrl("https://www.lolaflora.com/en-es/login");

            // Find the email/username textbox (by ID) on the login page
            var emailBox = safariDriver.FindElementById("EmailLogin");

            String [] wrongChar = { "!", ":", "?", ";", ",", "'", "%", "&", "/", "<", ">", "(", ")", "[", "]", "{", "}", "*" };

            Random random = new Random();
            int    rand   = random.Next(0, wrongChar.Length - 1);

            // Enter the mail adress for login
            emailBox.SendKeys("*****@*****.**" + wrongChar[rand]);

            // Find the password (by ID) on the login page
            var passwordBox = safariDriver.FindElementById("Password");

            // Enter the password for login
            passwordBox.SendKeys("123456789");

            // Find the search button (by Name) on the homepage
            var signIn = safariDriver.FindElementByXPath("//*[@id='userLogin']/div[6]/button");

            // Click "Submit" to start the search
            signIn.SendKeys(Keys.Return);

            try
            {
                Thread.Sleep(2000);
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine("Exception:" + e);
            }

            //Find an element on page after login
            var failLoginRemark = safariDriver.FindElementByXPath("//*[@id='userLogin']/div[2]/span[1]");

            try
            {
                Thread.Sleep(2000);
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine("Exception:" + e);
            }

            //[email protected]
            //123654789

            safariDriver.Dispose();
        }
コード例 #3
0
        public void WithoutAtCharOnMailAddress()
        {
            //For Mac Inıtialize the Safari Driver
            SafariDriver safariDriver = new SafariDriver();

            // Maximize the browser
            safariDriver.Manage().Window.Maximize();

            // Go to the "Lolaflora" login page
            safariDriver.Navigate().GoToUrl("https://www.lolaflora.com/en-es/login");

            // Find the email/username textbox (by ID) on the login page
            var emailBox = safariDriver.FindElementById("EmailLogin");

            // Enter the mail adress for login
            emailBox.SendKeys("testusertestuser.com");

            // Find the password (by ID) on the login page
            var passwordBox = safariDriver.FindElementById("Password");

            // Enter the password for login
            passwordBox.SendKeys("123654789");

            // Find the search button (by Name) on the homepage
            var signIn = safariDriver.FindElementByXPath("//*[@id='userLogin']/div[6]/button");

            // Click "Submit" to start the search
            signIn.SendKeys(Keys.Return);

            try
            {
                Thread.Sleep(2000);
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine("Exception:" + e);
            }

            //Find an element on page after login
            var failLoginRemark = safariDriver.FindElementByXPath("//*[@id='userLogin']/div[2]/span[1]");

            try
            {
                Thread.Sleep(2000);
            }
            catch (NullReferenceException e)
            {
                Console.WriteLine("Exception:" + e);
            }

            //[email protected]
            //123654789


            safariDriver.Dispose();
        }
コード例 #4
0
        public void SearchRouteTest()
        {
            safari.Navigate().GoToUrl("https://www.bahn.com/en");
            safari.FindElement(By.Id("js-auskunft-autocomplete-from")).SendKeys("Berlin");
            safari.FindElement(By.Id("js-auskunft-autocomplete-to")).SendKeys("Aalen");
            safari.FindElement(By.ClassName("js-submit-btn")).SendKeys(Keys.Enter);
            var ResultContent = safari.FindElementByClassName("resultContentHolder").Enabled;

            Assert.IsTrue(ResultContent);
        }
コード例 #5
0
ファイル: Browser.cs プロジェクト: qa-nparekh/ToolsQA
        public static IWebDriver OpenSafariBrowserWithUrl(IWebDriver driver, string strUrlToOpen, Boolean OpenInNewWindow = false)
        {
            try
            {
                Uri remote_grid = new Uri("http://" + "localhost" + ":" + "4444" + "/wd/hub");
                DesiredCapabilities capability = null;

                string browser = "safari";
                //if (browser == null || browser.Contains("safari"))
                {
                    //SafariProfile profile = new SafariProfile();

                    capability = DesiredCapabilities.Safari();
                    capability.IsJavaScriptEnabled = true;

                    //profile.EnableNativeEvents = true;

                    //capability.SetCapability(SafariDriver.ProfileCapabilityName, profile);
                }

                SafariOptions so = new SafariOptions();
                so.AddAdditionalCapability(DesiredCapabilities.Safari().IsJavaScriptEnabled.ToString(), true);

                //DesiredCapabilities capabilities = DesiredCapabilities.Safari();
                //capabilities.BrowserName.Insert(0, "safari");
                //ICommandExecutor executor = new SeleneseCommandExecutor( "http:localhost:4444/" ,"http://www.google.com/" , capabilities);
                //IWebDriver driver1 = new RemoteWebDriver(executor, capabilities);

                driver = new SafariDriver(so); // ScreenShotRemoteWebDriver(remote_grid, capability);
                //driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(20));

                WebDriverBackedSelenium BackedSelenium = new WebDriverBackedSelenium(driver, remote_grid);
                BackedSelenium.Start();

                driver.Navigate().GoToUrl(strUrlToOpen);
                Report.AddToHtmlReportPassed("Safari Browser Open for '" + strUrlToOpen + "' .");
                new Common(driver).pause(70000);
                driver.Manage().Window.Maximize();

                //ScreenShotRemoteWebDriver sd = new ScreenShotRemoteWebDriver(remote_grid, capability);
                //sd.GetScreenshot().SaveAsFile()
            }
            catch (Exception ex)
            {
                //Console.WriteLine("ex::" + ex);
                //Console.WriteLine("ex.Message::" + ex.Message);
                //Console.WriteLine("ex.InnerException::" + ex.InnerException);
                //Console.WriteLine("ex.StackTrace::" + ex.StackTrace);
                //Report.AddToHtmlReportFailed(driver, ex, "Safari Browser Open for '" + strUrlToOpen + "' .");
            }
            return(driver);
        }
コード例 #6
0
        public ReturnModel TestStartSafari()
        {
            ReturnModel testOk = new ReturnModel();

            try
            {
                IWebDriver driver = new SafariDriver();
                string     link   = @"http://www.n11.com/";
                driver.Navigate().GoToUrl(link);

                //LOGİN KISMI

                //driver.FindElement(By.ClassName("btnSignIn")).Click();
                //driver.FindElement(By.Id("email")).SendKeys("*****@*****.**");
                //driver.FindElement(By.Id("password")).SendKeys("tutkutektaspassword");
                //driver.FindElement(By.Id("loginButton")).Click();

                //Arama sonucunda 2. sayfa seçilme işlemi ve rastgele bir ürünü seçme işlemi

                driver.FindElement(By.Id("searchData")).SendKeys("Bilgisayar");
                driver.FindElement(By.ClassName("searchBtn")).Click();
                driver.FindElement(By.XPath(".//*[@id='contentListing']/div/div/div[2]/div[4]/a[2]")).Click();//Eğer burada hata veriyor ise div[4] olan kısım div[3] yapın
                //Yukardaki kodda .XPATH ile tüm sayfada döndük id si contentListing içine girip en alttaki 2. seçeneği seçtirdik.
                //Bunları yaparken contentListing içinde tek div var ona girdik sonra o divin içindede tek div var
                //3. kısımda 2 tane div var biz ortadaki olan div[2] yi seçtik. Son kısımda 4 div var. en altta sayfa geçişlerini sağlayan 4.Divi seçtik
                //4.Divin içindende sayfa adlar 'a' ile sıralanmış o yüzden a2 yi seçtik.
                driver.FindElement(By.XPath(".//*[@id='p-402919973']/div[1]/a")).Click();

                //Son Kısım Sepet işlemleri
                driver.FindElement(By.ClassName("btnAddBasket")).Click();
                driver.FindElement(By.ClassName("iconBasket")).Click();
                driver.FindElement(By.ClassName("spinnerArrow")).Click();
                driver.FindElement(By.ClassName("svgIcon_trash")).Click();

                testOk.IsSuccess = true;
            }
            catch (Exception ex)
            {
                testOk.IsSuccess    = false;
                testOk.ErrorMessage = "Hata : " + ex.Message;
            }
            return(testOk);
        }
コード例 #7
0
        public void LogInTest()
        {
            safari = new SafariDriver();
            safari.Navigate().GoToUrl("https://www.bahn.de/p/view/meinebahn/login.shtml");
            safari.FindElement(By.Id("Benutzername")).SendKeys("gaga231772");
            safari.FindElement(By.Id("Passwort")).SendKeys("gaga2317");
            safari.FindElement(By.ClassName("btn")).SendKeys(Keys.Enter);
            var  username   = safari.FindElementByClassName("nobttommargin").FindElement(By.TagName("span")).GetProperty("title");
            bool isUsername = false;

            if (username == "Evgenij Bondarik")
            {
                isUsername = true;
            }
            else
            {
                isUsername = false;
            }
            Assert.IsTrue(isUsername);
        }