ohmydengzi
8/8/2018 - 1:09 PM

selenide.java

package deng1;

import static com.codeborne.selenide.Selenide.*;
import static com.codeborne.selenide.Condition.*;

import org.openqa.selenium.By;
import org.testng.annotations.BeforeClass;
//import org.testng.*;
import org.testng.annotations.Test;

/**
 * Hello world!
 *
 */
public class App 
{
    public static void main( String[] args )
    {
        System.out.println( "Hello World!" ); 
    }
    
    @BeforeClass
    public void setBrowser() {
    	System.setProperty("webdriver.chrome.driver","D:\\Python27\\chromedriver.exe");
        System.setProperty("selenide.browser", "Chrome");
    }
    
    
    public void userCanLoginByUsername() {
    	open("http://master.com/?r=user/default/login");
    	$(By.name("username")).setValue("admin");
    	$(By.name("password")).setValue("123456");
    	$(By.name("loginsubmit")).click();
    	//$(".loading_progress").should(disappear); // Waits until element disappears
    	//$("#username").shouldHave(text("Hello, Johny!")); // Waits until element gets text
    }
    
    @Test
    public void test1() {
    	userCanLoginByUsername();
    	close();
    }
    
    @Test
    public void test2() {
    	userCanLoginByUsername();
    }
}