วันพฤหัสบดีที่ 16 มีนาคม พ.ศ. 2560

Nunit3 Running on command line

Nunit3 Running on command line

Prepare...

1. Download & install "Nunit3-console.msi or Nunit3-console.zip"

 Run...

2. Open CMD.exe 

3. Go to Path  of Nunit3-console.exe "cd Path"

ex. "cd C:\Users\Documents\Visual Studio 2015\Projects\nunit-console"

4. Complie your code at visual studio 2015 for get UnitTestProject.dll

5. Run UnitTestProject.dll on CMD "nunit3-console path+UnitTestProject2.dll"

ex. nunit3-console "C:\Users\Documents\Visual Studio 2015\Projects\ConsoleApplication1\UnitTestProject2\bin\Debug\UnitTestProject2.dll"


Library 

--where "cat == //A category assigned to the test
nunit3-console "C:\Users\Documents\Visual Studio 2015\Projects\ConsoleApplication1\UnitTestProject2\bin\Debug\UnitTestProject2.dll" --where "cat == A"

--where "method == //only a method
nunit3-console "C:\Users\Documents\Visual Studio 2015\Projects\ConsoleApplication1\UnitTestProject2\bin\Debug\UnitTestProject2.dll" --where "method != TestMethod1"

--where "name == //all test mathod name
nunit3-console "C:\Users\Documents\Visual Studio 2015\Projects\ConsoleApplication1\UnitTestProject2\bin\Debug\UnitTestProject2.dll" --where "name == TestMethod1"

--where "class == //all test attributed in this class
nunit3-console "C:\Users\Documents\Visual Studio 2015\Projects\ConsoleApplication1\UnitTestProject2\bin\Debug\UnitTestProject2.dll" --where "class == UnitTestProject2.UnitTest1"

--where "test == //all test attributed in this class
nunit3-console "C:\Users\Documents\Visual Studio 2015\Projects\ConsoleApplication1\UnitTestProject2\bin\Debug\UnitTestProject2.dll" --where "test == UnitTestProject2.UnitTest1"


--workers=
nunit3-console "C:\Users\Documents\Visual Studio 2015\Projects\ConsoleApplication1\UnitTestProject2\bin\Debug\UnitTestProject2.dll" --where "class == UnitTestProject2.UnitTest1" --workers=7

วันพฤหัสบดีที่ 9 มีนาคม พ.ศ. 2560

Selenium Java Quickly Setup on Eclipse


Selenium Java Quickly Setup on Eclipse

Prepare...

Hint: It's very sensitive about version!! 
Hint 2: Download Type 32 bit is better...

Eclipse neon [Download & Install]

https://www.eclipse.org/downloads/download.php?file=/oomph/epp/neon/R2a/eclipse-inst-win64.exe

Java JDK [Download & Install]

http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

Chrome Driver [Download]

https://chromedriver.storage.googleapis.com/index.html?path=2.27/

Geckodriver (V 0.14) [Download]

https://github.com/mozilla/geckodriver/releases

Firefox Browser [Install]


Chrome Browser [Install]


===============================================================

To do....

1. Create Java Project

include main

2. Put every thing in your Project Path

chromedriver
geckodriver

3. Import Library of Selenium By get Code from this site

https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java/3.2.0
https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server/3.2.0

4. Insert to  pom.xml in Project @ Eclipse. It's auto-update.

  <dependencies>
  <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-server -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-server</artifactId>
    <version>3.2.0</version>
</dependency>

  <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
<dependency>
    <groupId>org.seleniumhq.selenium</groupId>
    <artifactId>selenium-java</artifactId>
    <version>3.2.0</version>
</dependency>
  </dependencies>

5. Code test here "Run on Firefox"

package testSelenium;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class test {

public static void main(String[] args) {
// TODO Auto-generated method stub
        WebDriver driver = new FirefoxDriver();

        // And now use this to visit Google
        driver.get("http://www.google.com");
        // Alternatively the same thing can be done like this
        // driver.navigate().to("http://www.google.com");
     // Should see: "cheese! - Google Search"
        //System.out.println("Page title is: " + driver.getTitle());
        
        //Close the browser
        driver.quit();
        
}

}

6. Code test here "Run on Chrome"

package testSelenium;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class test {

public static void main(String[] args) throws InterruptedException {
// TODO Auto-generated method stub
System.setProperty("webdriver.chrome.driver", "chromedriver.exe");

 WebDriver driver = new ChromeDriver();
 driver.get("http://www.google.com/xhtml");
 Thread.sleep(5000);  // Let the user actually see something!
 WebElement searchBox = driver.findElement(By.name("q"));
 searchBox.sendKeys("ChromeDriver");
 searchBox.submit();
 Thread.sleep(5000);  // Let the user actually see something!
 driver.quit();
}

}

วันจันทร์ที่ 6 มีนาคม พ.ศ. 2560

C# Complier and Run Without Visual Studio

C# Complier and Run Without Visual Studio

If you don't have any file.cs To do this below.

Open Notepad

1. Put this code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace Chapter1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("This is my First C# Program");
            Console.ReadLine();
        }
    }
}

2. Save with "Chapter1.cs"


==============================================

Open Visual Studio Command Prompt.

0. cd yourFolder ie. cd C:\Users\Documents\Training

1. Complier> "csc Chapter1.cs"

2. Run> "Chapter1"

Output!!
This is my First C# Program

วันอาทิตย์ที่ 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();
            }
        }
    }
}


Nunit3 Running on command line

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