วันอาทิตย์ที่ 5 มีนาคม พ.ศ. 2560

Selenium C# Setup Tutorial with visual studio

Selenium C# Setup Tutorial with visual studio

Start With Selenium!

Automate test is famous so, we go learn tool now.

1. Install "Visual Studio 2015"++
2. Open new "website Project"


เพิ่มคำอธิบายภาพ

3. Getting new web form


4. Hit "Tool" > "NugetPackage" > "Management Solution..."



5. Hit "Browse" >  Search "Selenium" > Install "WebDriver", "Support"
Choose "Chrome/IE/Firefox"


6. Double Click on "Default.aspx.cs" then put your code.


7. Example code

using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using System;
using OpenQA.Selenium.Support.UI;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            using (IWebDriver driver = new ChromeDriver())
            {              
                driver.Navigate().GoToUrl("http://www.google.com/");

                IWebElement query = driver.FindElement(By.Name("q"));

                query.SendKeys("ถุงเท้าขายส่ง");

               query.Submit();

                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
                wait.Until(d => d.Title.StartsWith("cheese", StringComparison.OrdinalIgnoreCase));

                Console.WriteLine("Page title is: " + driver.Title);
                Console.ReadLine();
            }
        }
    }
}


1 ความคิดเห็น:

Nunit3 Running on command line

Nunit3 Running on command line Prepare... 1. Download & install "Nunit3-console.msi or Nunit3-console.zip"  Run... 2....