Selenideã¨ã¯
ãSelenideã¨ã¯ãã¨ã¹ããã¢ã«ããCodeborne社ã®Andrei Solntsevæ°ãä¸å¿ã«éçºãè¡ããã¦ããWebDriverã®Javaã©ããã¼ã®ä¸ã¤ã§ãåãJavaã§å®è£ ãããFluentLeniumãGroovyã§ã®Gebã«ç¸å½ãããã®ã§ããWebDriverã¯ããã°ã©ã ãããã©ã¦ã¶ãæä½ããAPIãæä¾ãã¦ãã¾ãããåºæ¬çã«ä½ã¬ãã«APIã§èªåãã¹ããè¨è¿°ããã«ã¯å¤§éã®ã³ã¼ããå¿ è¦ã¨ãªãã¾ããSelenideã¯WebDriverãåºç¤ã¨ããªããé«æ°´æºAPIãæä¾ãããã¨ã§ãWebDriverãç´ ã§ä½¿ãããã容æã«ãã¤è¨è¿°éãæãã¦ãã¹ããè¨è¿°ãããã¨ãã§ãã¾ãã
Selenideã®ç¹å¾´
ã以ä¸ã§ã¯Selenideã®ç¹å¾´ãè¿°ã¹ã¦ããã¾ãããããã®ä¸ã«ã¯ä¸è¨ã§æããFluentLeniumãGebã§ãæä¾ããã¦ãããã®ãããã¾ãï¼ãã¹ã¦ãSelenideåºæã¨ãããã¨ã§ã¯ããã¾ããï¼ã
è¦ç´ åå¾ã»ãã§ãã¯ãªã©ã®é«æ°´æºAPIã®æä¾
ãFluentLeniumãGebãªã©ã®ä»ã®é¡ä¼¼ãããã¯ãã«ãããã¾ãããHTMLä¸ã®è¦ç´ åå¾ãç¶æ å¤å®ãAssertionã®é«æ°´æºAPIãæä¾ããã¾ããSelenideã®ãµã³ãã«ã«ããããã«ä»¥ä¸ã®ããã«æ¸ãã¾ãã
import static com.codeborne.selenide.Selenide.*; import static com.codeborne.selenide.Condition.*; @Test public void userCanLoginByUsername() { open("/login"); $(By.name("user.name")).setValue("johny"); $("#submit").click(); $(".loading_progress").should(disappear); // Waits until element disappears $("#username").shouldHave(text("Hello, Johny!")); // Waits until element gets text }
ãæ®æ®µJavaã§ã³ã¼ããæ¸ãã¦ããã¨è²ã é©ããã¨ãããã¾ãããã®ãµã³ãã«ã³ã¼ããè¦ãã ãã§ã以ä¸ã®ãããªãã¨ã«æ°ãã¤ãã¨æãã¾ãã
- åæå¦çãè¡ã£ã¦ããªãã®ã«åãã
-
ã
$
ãã§ã»ã¬ã¯ã¿ãå§ã¾ãã - ã»ã¬ã¯ã¿ãjQuery風ã«ã¤ãããã
-
ã¯ãªãã¯ã
click()
ã¡ã½ããã§æ¸ãã -
should()
ãshouldHave()
ã§Assertionãè¡ããã -
text("hoge")
ã§ããã¹ãã®ç¶æ ãå¤å®ã§ããã
static import ãå©ç¨ããDSLã®æä¾
ãåè¿°ã®é«æ°´æºAPIã¨éè¤ããé¨åãããã¾ãããJava 5ããå°å ¥ãããstatic importãå©ç¨ããDSL風ã®è¨è¿°ãè¡ããããã«ãªã£ã¦ãã¾ãã
ãå
ã®ãµã³ãã«ã³ã¼ãã§ãåºã¦ããã$
ãã¨ããã¡ã½ããã¯com.codeborne.selenide.Selenide
ã¨ããã¯ã©ã¹ã®static methodã§ããããã¹ãã³ã¼ãã§static importãè¡ããã¨ã§ããããjQueryã使ã£ã¦ãããã®ããã«èªç¶ã«ã»ã¬ã¯ã¿ãè¨è¿°ã§ãã¾ãã
ãä»ã«ãcom.codeborne.selenide.Condition
ã¨ããç¶æ
ã表ç¾ããã¯ã©ã¹ããããstatic field ã¨ãã¦ä»¥ä¸ã®ãããªãã®ãå®ç¾©ããã¦ãã¾ãã
- appear
- disappear
- enable
- disabled
- empty
- checked
ããµã³ãã«ã³ã¼ãä¸ã®ä»¥ä¸ã§ä½¿ããã¦ããdisappear
ãã¾ãã«ãã®Condition.disappear
ã§ãããstatic importã使ããã¨ã§èªç¶è¨èªï¼ãã®å ´åã¯è±èªã§ããï¼ã®ãããªæãã§è¨è¿°ãããã¨ãã§ãã¾ãã
$(".loading_progress").should(disappear);
ãä»ã«ã$
ã¡ã½ããã¨çµã¿åããã¦ä½¿ããæ¤ç´¢æ¡ä»¶ã§ããcom.codeborne.selenide.Selectors
ã使ããã¨ã§ä»¥ä¸ã®ããã«è¨è¿°ã§ãã¾ãã
$(byId("employeeTree")).click()
ãããã§ã®byId
ã¯Selectors#byId
ãstatic import ããçµæã§ãã
Page Objectãã¿ã¼ã³ãæ¨æºã§ãµãã¼ã
ãSelenideã¯æ¨æºã§Page Objectãã¿ã¼ã³ããµãã¼ããã¦ãã¾ãã
ãpage(PageClass.class)
ãopen("http://example.com/hoge.html", HogePage.class)
ã§æå®ããPageObjectãçæãã¾ãããã®éã対象Page Objectã®fieldã«@FindBy
ã§æ¤ç´¢æ¡ä»¶ãæå®ãã¦ãããã¨ã§ããã®æ¤ç´¢çµæãè¨å®ããã¾ãã
ã詳細ã¯PageObjectã使ç¨ãããµã³ãã«ã³ã¼ãããåç §ãã ããã