èªåãã¹ãã·ã¹ãã ãäœæããå¿ èŠãããäž»ãªçç±ã¯ãã¢ããªã±ãŒã·ã§ã³ãæ°ããCMSïŒããããPageBuilderïŒã«åãæ¿ããããšãèšç»ããŠããããã§ãã ãã®çš®ã®ç§»è¡ã§ã¯ãããŸããŸãªããŒãžã§æ°ããCMSãéããŠå ¬éãããã³ã³ãã³ããé©åã«èŠããããã«ããã¹ãããªãããšãéåžžã«éèŠã§ãã
ãã¹ãŠã®ããŒãžããã¹ãã«æºæ ããŠãããã©ããã確èªããäœæ¥ã¯ãããŸããã ç§ãã¡ã®ã¿ã¹ã¯ã¯ãPageBuilderã®ãã°ãç¹å®ããçŒãããŠã®PageBuilderã«ãã£ãŠäœæãããããŒãžã®ã¬ã€ã¢ãŠãã®ä¿¡é Œæ§ã確èªããç¹å®ã®ããŒãžãããŒãžè¡šç€ºã®æœåšçãªåé¡ã«ã€ãªããå¯èœæ§ã®ããã³ã³ãã³ãã§åãããšãããã¥ã¢ã³ã¹ã«Washingtonpostãšãã£ã¿ãŒã®æ³šæãåŒãä»ããããšã§ãã
ãã¹ãã·ã¹ãã ã®äœæã¯æŽ»çºã«éçºãããŠããŸãããç§ãã¡ã®æèŠã§ã¯ãããã€ãã®èå³æ·±ãç¹ããã§ã«äžè¬ã«å ¬éãããŠããŸãã
ãããè¡ãåã«ããããžã§ã¯ãã®1ã€ã®æ©èœã«æ³šæããå¿ èŠããããŸãããã¹ãŠã®ãã¹ãã¯ãå€éšãã§è¡ãããŸãã ã€ãŸã ç§ãã¡ã¯ãä»ã®ãŠãŒã¶ãŒãšåæ§ã«ããã¹ãçšã«æŠéããŒãžã§ã³ã®ãµã€ãã䜿çšããŸãã
ã¬ã€ã¢ãŠããã¹ãããŒã«ã®éžæ
ã€ã³ã¿ãŒããããæ¢çŽ¢ããåŸã次ã®ã¢ãããŒããšããŒã«ã«æ±ºããŸããã ããŒãžãã¬ãŒã ããã¹ãããããã«ãåŸã§testNGãšçµ±åããGalenãã¬ãŒã ã¯ãŒã¯ãæ¡çšããŸããã
åœç¶ãããŒãžãã¬ãŒã ã®ã¬ã¬ã³ãã¹ãã«åæ ŒããŠããã¬ã€ã¢ãŠãã®æå¹æ§ãæå³ããããã§ã¯ãããŸããã ãããã¯ã®å Žæã«å ããŠããããã¯å ã®ããŸããŸãªèŠçŽ ã®è¡šç€ºã確èªããå¿ èŠããããŸãã ã¹ã¯ãªãŒã³ã·ã§ãããæ¯èŒããŠããããã¯ã®å éšã³ã³ãã³ãããã¹ãããããšã«ããŸããã
ããŸããŸãªããŽããã¿ã³ãç¹å®ã®ãã£ã¹ãã¬ã€ãåããäžéšã®ãããã¯ã¯ãã¹ã¯ãªãŒã³ã·ã§ãããã¹ãã«ç¿»åŒãããŸããGalenãå°éã§ãããæ©èœãã¹ãã§æ€èšŒããããšãå°é£/äžå¯èœã§ãããã¹ãŠã§ãã
Azure-Galenã«ãã£ãŠãã¹ããããç·è²ã§ããµããŠãã-ã¹ã¯ãªãŒã³ã·ã§ãããã¹ãïŒ
ã泚æ å šäœå
é衚瀺ã®ããã¹ã
ã¬ã¬ã³ãšã¹ã¯ãªãŒã³ã·ã§ããã®ãã¹ãã¯ãããã€ãã®æ©èœãã¹ããæ£åžžã«çœ®ãæããããšãã§ããåæã«èŠèŠåãé床ããããŠäž¡æ¹ã§åå©ããããšãã§ããŸãã ç¹å®ã®ã±ãŒã¹ã®ãã¹ãæ¹æ³ã®éžæã¯ãããã©ãŒãã³ã¹åºæºããµããŒãã®å®¹æãããã¹ãç¯å²ã®å®å šæ§ãããã³å¯èŠæ§ã«åºã¥ããŠãããŒãžã®çš®é¡ããšã«ãã¹ãã±ãŒã¹ããŸãšããŠè°è«ããããšã«ããè¡ãããŸãã
ããšãã°ãæåã«æ©èœãã¹ããèšè¿°ããæ€èšŒçšãããã¯ã«ã¯ãMost Readãããã¯ãšInformation Blockã®2ã€ããããŸãã ä»åºŠã¯ãã¹ã¯ãªãŒã³ã·ã§ããã§æåããã§ãã¯ããã¬ã¬ã³ãã¹ãã§2çªç®ããã§ãã¯ããŸãã
MostReadãããã¯ãã¹ã¯ãªãŒã³ã·ã§ãããã¹ãã«ããæ€èšŒïŒ
æ©èœãã¹ãã«é¢ããŠïŒã³ãŒãã®è¡ãã¯ããã«å°ãããªãããã¹ãã«ãã¬ããžã®å®å šæ§ãåäžããããŒãžäžã®ãã®ãããã¯ã®å€èŠ³ãå€æŽãããšãã«ãã¹ããæŽæ°ããã®ã«ããã»ã©æéã¯ããããŸããã
ãã®ãããã¯ã®ãã¹ãã¯ãã¹ã¯ãªãŒã³ã·ã§ããæ¹åŒã®ç« ã§æ€èšãããŠããŸãã
WaPoæ å ±ãããã¯ïŒ
Galenã¯ãã®ãããã¯ã®ããã¹ããšãªã³ã¯ã®å¯Ÿå¿ãåé¡ãªããã§ãã¯ããŸãããªã³ã¯èªäœã¯ãã±ãŒã¿ãŒã§æå®ãããããã¹ããšå éšã¬ã¬ã³ãã§ãã¯ãšã®å¯Ÿå¿ã¯ç¢ºèªãããŸãã æ©èœãã¹ãã«é¢ããŠã¯ããã¹ãç¯å²ã®å®å šæ§ã¯å€æŽãããŠããŸãããããã¹ããåäžã®ãã¹ãã®äžéšãšããŠå®è¡ããããšããäºå®ã«ãããæéãå€§å¹ ã«ç¯çŽã§ããŸãã
ã¬ã¬ãã¹ãã¹ãã³ãŒã ã
åœç€Ÿã®èªåãã¹ãã·ã¹ãã ã¯ãJavaãMavenãTestNGã Selenium WebDriver ãSelenium Gridã Galen Frameworkã䜿çšããŠããŸãã
ã¹ã¯ãªãŒã³ã·ã§ããããŒã¹ã®ãã¹ããäœæããéã«ã ImageMagickãŠãŒãã£ãªãã£ã®ã¯ãã¹ãã©ãããã©ãŒã ã»ãããç©æ¥µçã«åœ¹ç«ã¡ãŸãã
PageObjectãã¿ãŒã³ãšYandex- HTML Elementsã®ãã¬ãŒã ã¯ãŒã¯ã䜿çšããŠJavaã§ãã¹ãã³ãŒããèšè¿°ããŠããããšã«ããã«æ³šç®ããŸã ã ãã¹ããå®è¡ããã«ã¯ãmavenãštestNGã䜿çšãããŸãã
ãã¹ãã®ç«ã¡äžãã容æã«ããããããã¹ãã®ç«ã¡äžãã®å±¥æŽã衚瀺ããé«åºŠãªè³æ Œãæã€å°é家ãé¢äžããããšãªãã¬ããŒãã衚瀺ããããã«ãå¥ã®ã¢ããªã±ãŒã·ã§ã³-ããã·ã¥ããŒããéçºããŠããŸãã
çŸåšããã¹ãããã»ã¹å šäœãé©åã«æŽçããæ¹æ³ã«ã€ããŠã¯ãŸã ç 究段éã«ããããã¹ãŠã®ã¢ãããŒããå®å šã«ãã¹ã¿ãŒãããç 究ãããŠããããã§ã¯ãªãããšã匷調ããŠãããšåœ¹ç«ã¡ãŸãã
Galen Frameworkã䜿çšãããã¹ã
Galen Frameworkã«ã¯å€ãã®åŠå®ã§ããªãå©ç¹ããããŸããã¬ã¹ãã³ã·ããã¶ã€ã³ã®ããã®åºç¯ãªãã¹ãæ©èœãåãããæè»ã§äœ¿ããããããŒã«ã§ãã ããã«ãååã«ææžåãããŠãããçŸåšç©æ¥µçã«éçºäžã§ãã
Galen Frameworkã¯ããã§ã«èšäºã® 1ã€ã§åå詳现ã«èª¬æãããŠããŸãã Galenã§ã®äœæ¥ã®ååãç°¡åã«èª¬æãããšã次ã®ããã«ãªããŸããç¹å¥ã«ææžåãããçŽæçãªæ§æã䜿çšããŠããŒãžä»æ§ïŒããããspecãã¡ã€ã«ïŒãèšè¿°ããŸãã ä»æ§ãã¡ã€ã«ã«ã¯ãããŒãžèŠçŽ ã®çžå¯Ÿçãªäœçœ®ããµã€ãºãã€ã³ãã³ãããã¹ããããã³ããŒãžã¬ã€ã¢ãŠããæºæ ãã¹ããã®ä»ã®ãã©ã¡ãŒã¿ãŒãšæ¡ä»¶ãèšè¿°ãããŠãããèŠçŽ å ã®ããã¹ãã®å¯Ÿå¿ã確èªããããšãã§ããŸãã ãããŠããããã®ãã§ãã¯ã¯ãã¹ãŠãæå®ããã¿ã°ã«å¿ããŠé©çšãããŸãã
specãã¡ã€ã«ã®ã¿ã°ã¯æ¬¡ã®ããã«æå®ã§ããŸãã
Galenã¯ãã¹ãŠã®ãã§ãã¯ãå®è¡ããŠãããhtmlãã¡ã€ã«ã®åœ¢åŒã§èŠèŠçãªã¬ããŒããçæããŸãã ã¬ããŒãã«ã¯ããã®ãã¹ãã§å€±æããç¹å®ã®ãã§ãã¯ã瀺ããã倱æããåãã§ãã¯ã«ã€ããŠãç¹å®ã®ãã¹ãã«åæ Œããªãã£ãèŠçŽ ã匷調衚瀺ããããã¹ãæžã¿ããŒãžã®å®å šãªã¹ã¯ãªãŒã³ã·ã§ãããèŠãããšãã§ããŸãã
ããšãã°ãé£æ¥ããèŠçŽ éã®è·é¢ã®ãã¹ãã«å€±æãããšãã¬ããŒãã§ã¯æ¬¡ã®ããã«ãªããŸãã
èµ€ã§åŒ·èª¿è¡šç€ºããããã§ãã¯ãã¯ãªãã¯ãããšããã§ãã¯ãããããŒãžå šäœã®ã¹ã¯ãªãŒã³ã·ã§ããã衚瀺ããããã®ãããªèŠçŽ ã匷調衚瀺ãããŸãã
Galen Frameworkã¯ã次ã®ãã©ã¡ãŒã¿ãŒãå ¥åãšããŠåãå ¥ããŸãã
- ãã§ãã¯ãè¡ããããã©ãŠã¶
- ãã¹ããå®è¡ããèš±å¯
- ãã¹ããããããŒãžã®URL
- .specãã¡ã€ã«ã®ãã§ãã¯ãéå§ããåã«ãèµ·åããããŒãžã«é©çšããå¿ èŠãããïŒå¿ èŠãªå ŽåïŒJavaScriptãã¡ã€ã«ïŒããšãã°ããµã€ãã«ãã°ãªã³ããŠãããŠãŒã¶ãŒãžã®ããŒãžè¡šç€ºã確èªããå¿ èŠãããå ŽåïŒ
- èµ·åããã.specãã¡ã€ã«ã®åå
- .specãã¡ã€ã«ã®ãã§ãã¯ã«é©çšããå¿ èŠãããã¿ã°ïŒããšãã°ããã¹ã¯ããããDestopã®ã¬ã€ã¢ãŠãããã¹ãããå Žåã¯allïŒã
ã芧ã®ãšãããGalenã«æäŸããããã©ã¡ãŒã¿ãŒãå€æŽããããšã§ããµã€ãã®ãã¬ãŒã ã¯ãŒã¯ã®ã»ãŒå®å šãªãã¹ãã«ãã¬ããžãéæã§ããŸãã
ãµã€ãã¯ã€ã€ãã¬ãŒã ãã¹ãããŒã«ã決å®ãããã次ã®ã¿ã¹ã¯ã¯ãGalenãã¹ãã§ããŒãžã®æ倧ã«ãã¬ããžãæäŸã§ããã¹ããŒã ãéžæããããšã§ããã
åãã¿ã€ãã®ããŒãžã®ãµãã»ãããããã¹ãããŒãžãéžæãã
ãã¹ããåãã¿ã€ãã®ããŒãžã®å€ãããã§ãã¯ããããã«èšèšãããŠããå Žåãã¬ã€ã¢ãŠãããã¹ãããããã«éžæããããŒãžã¯ã©ãã§ããïŒ
ç¹ã«æ°ã«ããããšãªãããã¹ãã¹ã€ãŒããå®è¡ãããã³ã«ãµãã»ããããã©ã³ãã ããŒãžãéžæããããšã«ããŸããïŒã€ãŸããã¬ã·ãããŒãžã®ãµãã»ããããã¹ãããããã«ãã¬ã·ãã®1ã€ãéžæãããã®URLããã¹ãŠã®ã¬ã€ã¢ãŠããã¹ãã«æž¡ããŸãïŒã ãããã£ãŠãã¿ã¹ã¯ã®ãã¹ãŠã®ããŒãžããã§ãã¯ãã䟡å€ããªããããã©ã³ãã ããŒãžãéžæãããªãã·ã§ã³ãæé©ã§ããããã«èŠããŸããã ãã§ãã¯ãããããŒãžã®ãµãã»ããã®ã©ã³ãã ããŒãžã®URLã¯ãèªåãµã€ããã¹ãã·ã¹ãã å ã®ãã¹ãŠã®ãã¹ãã«å ±éã®æ¹æ³ã§Galenã«éä¿¡ãããŸãïŒçµçãã¹ããé€ããæ©èœãã¹ããšã¹ã¯ãªãŒã³ã·ã§ãããã¹ãããããŸãïŒã
ããšãã°ãåãã¿ã€ãã®ããŒãžã衚瀺ããããã®2ã€ã®ãªãã·ã§ã³ããããŸã-ã¬ã·ãã®ããŒãžã§ããã®ãã¡ã®1ã€ã«ãšã©ãŒãå«ãŸããŠããŸãïŒ
ãã®äŸã¯ãããŒãžã®å³åŽã®åã«é 眮ããå¿ èŠããããMost Readããããã¯ããã¡ã€ã³ããŒãžã®å·ŠåŽã§ã¯ãªãå³åŽã«ããããšã瀺ããŠããŸãã ãã®çš®ã®åé¡ããªãããšã確èªããã«ã¯ãå€æ°ã®ããŒãžã確èªããå€ãã®èŠå ãèæ ®ããå¿ èŠããããŸãã
ã©ã®æš©éã§ãã¹ããå®è¡ããŸããïŒ
æåã«ãæãäžè¬çãªããã€ã¹ãéžæãããã®è§£å床ã䜿çšããŠãã¹ããå®è¡ãããšããã¢ã€ãã¢ãçãŸããŸããã ããããææã®å éãããåå¡ã®æ確ã«è¿œè·¡ãããåŸåã¯ãç§ãã¡ããã®åéã®ç¡æ¡ä»¶ã®æå°è ãéžæããïŒãããŠããã«äºæž¬ããïŒããšãèš±ããŸããã Webã¢ããªã±ãŒã·ã§ã³ã衚瀺ã§ããããã€ã¹ã¯ãããããããŸãããæè¿ã§ã¯ãã®ãããªããã€ã¹ã«å¯Ÿããæš©éã®çµ±äžã¯çµ¶å¯Ÿã«æµè¡ããŠããŸããã çªç¶ã®ã¯ãªãŒãã³ã°ã¯ãä»»æã®æå¹ãªè§£å床ã§æ£ãã衚瀺ããããã«ã¢ãããã£ããã¶ã€ã³ãã¢ãããã£ãã§ãããšèããç§ãã¡ã®å¿ãæãããã®åéã®ãããªãç 究ã劚ããŸããã 決å®ãäžãããŸããããã¹ãŠã®æå¹ãªè§£å床ã§ã¬ã€ã¢ãŠãããã¹ãããŠããŸãã
æå¹ãªã¢ã¯ã»ã¹èš±å¯ã«ã¯ãæå°ãã¥ãŒããŒãå¹ = 241ãã¯ã»ã«ïŒãã©ãŠã¶ãŒãæžå°ããããšã¯ãããŸããïŒããæ倧ãã¥ãŒããŒãå¹ = 1920ãã¯ã»ã«ïŒäžéã¯åçŽãªèªçºçãªåªåïŒãŸã§ã®ãã¹ãŠã®ã¢ã¯ã»ã¹èš±å¯ãå²ãåœãŠãããŸããã èªåãã¹ãã®ããã®ãã¥ãŒããŒãã®é«ãã決å®ãã©ã¡ãŒã¿ã§ããããŒãžã¯ãŸã ãªãããããããŸã§ã®ãšããé«ãã«æ³šæãæããŸããã
ãã¹ãŠã®è§£å床ã§ã¬ã€ã¢ãŠãããã¹ãããæ¹æ³ã¯ïŒ
ãŸããæå¹ãªæš©éã®ç¯å²å šäœãç°ãªãã¬ã€ã¢ãŠãã®ç¯å²ã«åå²ãããŸããã ã¬ã€ã¢ãŠãèªäœã¯ããŽã ãã§ããããããã¯ã®é 眮ãç°ãªããããåºå¥ããããšãã§ããŸãã ã¬ã€ã¢ãŠãã®å¢çã決å®ããããšã¯é£ãããããŸããããã©ãŠã¶ã®é ã§ãã©ãã°ããããŒãžãããã¯ãã©ã®å¢çç¹ã§å€åãããã調ã¹ãŸãïŒçžå¯Ÿçãªäœçœ®ãæ°ãããã³/ãŸãã¯åäœã ç°¡ç¥åããããã«ããã¥ãŒããŒãã®å¹ ã®ã¿ãèæ ®ããŸãã 次ã®è¡šãå€æããŸããã
ãã¹ã¯ãããïŒæ倧1920ãã¯ã»ã«ãæå°1018ãã¯ã»ã«ã
ã©ãããããïŒæ倧1017pxãæå°769pxã
ã¿ãã¬ããïŒæ倧768ãã¯ã»ã«ãæå°481ãã¯ã»ã«ã
ã¢ãã€ã«ïŒæ倧480ãã¯ã»ã«ãæå°361ãã¯ã»ã«ã
SMALL_MOBILEïŒæ倧360ãã¯ã»ã«ãæå°280ãã¯ã»ã«ã
ã¡ãªã¿ã«ããã®ãããªè§£å床ã®ããã€ã¹ã§Washington Postã衚瀺ãããŠãŒã¶ãŒã®æ°ã¯æ²æšãªã»ã©å°ãªããããSMALL_MOBILEã¬ã€ã¢ãŠãããã¹ãããªãããšã«ããŸããïŒæšæž¬çãªçµè«ã§ãããããã«ãã¹ããè¿œå ããŠãåé¡ãããŸããïŒã ç°ãªãçµçã§4ã€ã®ç¯å²ããã¹ãããããã«æ®ããŸãã
以äžã¯ããã¹ã¯ãããã®ã¢ã¯ã»ã¹èš±å¯ã«ã€ããŠGalenãã¹ããå®è¡ããã³ãŒãã§ãã
é衚瀺ã®ããã¹ã
invokeGalenActionsã¡ãœããã¯ããã®ãã¬ãŒã ã¯ãŒã¯ã«ãã£ãŠæ¶åããã圢åŒã®ãã¹ãŠã®åææ¡ä»¶ãGalenã«æäŸããŸãã
GalenActionBuilderã䜿çšãããšãäž¡æ¹ã®ãã€ãã£ãã¬ã¬ã³ã®åææ¡ä»¶ïŒ.waitForVisibleïŒ5ã ".pb-f-ad-leaderboard> div> div> div> iframe"ïŒïŒãšé¢é£ïŒ.scrollToElementïŒ "ãPb- f-ad-flex "ïŒïŒïŒ
@Test(groups = { "Galen" }) @WebTest(value = "Verify that layout of Article page is not broken on desktop screen resolution.", bugs = {"#5599", "#5601", "#5600"}) public void testArticlepageLayoutOnDesktop() throws Exception { GalenActionsBuilder builder = new GalenActionsBuilder() //advertisement frames become visible only if advertisement placeholder is visible .waitForVisible(5, ".pb-f-ad-leaderboard > div> div > div > iframe") .scrollToElement(".pb-f-ad-flex") .waitForVisible(5, ".pb-f-ad-flex > div > div > iframe") .scrollToElement(".pb-f-ad-flex-2") .waitForVisible(5, ".pb-f-ad-flex-2 > div > div > iframe") .scrollToElement(".pb-f-ad-flex-3") .waitForVisible(5, ".pb-f-ad-flex-3 > div > div > iframe") .injectJavascript("/js/scroll_to_top.js") .waitSeconds(2) .check("/article.spec", Arrays.asList("all", "desktop")); invokeGalenActions(ArticlePage.getRandomArticlePage(), builder.build(), getRandomResolution(DESKTOP)); }
invokeGalenActionsã¡ãœããã¯ããã®ãã¬ãŒã ã¯ãŒã¯ã«ãã£ãŠæ¶åããã圢åŒã®ãã¹ãŠã®åææ¡ä»¶ãGalenã«æäŸããŸãã
protected void invokeGalenActions(String url, List<GalenPageAction> actions, Dimension... sizes) throws Exception { run(url, actions, recalculateSizes(sizes)); }
GalenActionBuilderã䜿çšãããšãäž¡æ¹ã®ãã€ãã£ãã¬ã¬ã³ã®åææ¡ä»¶ïŒ.waitForVisibleïŒ5ã ".pb-f-ad-leaderboard> div> div> div> iframe"ïŒïŒãšé¢é£ïŒ.scrollToElementïŒ "ãPb- f-ad-flex "ïŒïŒïŒ
public class GalenActionsBuilder { private boolean built; private final List<GalenPageAction> actions = new ArrayList<>(); public GalenActionsBuilder waitFor(Integer seconds, GalenPageActionWait.UntilType type, Locator locator) { checkUsed(); GalenPageActionWait.Until u = new GalenPageActionWait.Until(type, locator); GalenPageActionWait a = new GalenPageActionWait(); a.setTimeout(seconds * 1000); a.setUntilElements(Lists.newArrayList(u)); a.setOriginalCommand("wait " + seconds + "s until " + type.toString() + " " + locator.getLocatorValue()); actions.add(a); return this; } public GalenActionsBuilder waitSeconds(Integer seconds) { checkUsed(); GalenPageActionWait a = new GalenPageActionWait(); a.setTimeout(seconds * 1000); a.setOriginalCommand("wait " + seconds + "s"); actions.add(a); return this; } public GalenActionsBuilder waitForExist(Integer seconds, String cssSelector) { return waitFor(seconds, GalenPageActionWait.UntilType.EXIST, Locator.css(cssSelector)); } public GalenActionsBuilder waitForVisible(Integer seconds, String cssSelector) { return waitFor(seconds, GalenPageActionWait.UntilType.VISIBLE, Locator.css(cssSelector)); } public GalenActionsBuilder waitForHidden(Integer seconds, String cssSelector) { return waitFor(seconds, GalenPageActionWait.UntilType.HIDDEN, Locator.css(cssSelector)); } public GalenActionsBuilder waitForGone(Integer seconds, String cssSelector) { return waitFor(seconds, GalenPageActionWait.UntilType.GONE, Locator.css(cssSelector)); } public GalenActionsBuilder waitForExist(Integer seconds, Locator locator) { return waitFor(seconds, GalenPageActionWait.UntilType.EXIST, locator); } public GalenActionsBuilder waitForVisible(Integer seconds, Locator locator) { return waitFor(seconds, GalenPageActionWait.UntilType.VISIBLE, locator); } public GalenActionsBuilder waitForHidden(Integer seconds, Locator locator) { return waitFor(seconds, GalenPageActionWait.UntilType.HIDDEN, locator); } public GalenActionsBuilder waitForGone(Integer seconds, Locator locator) { return waitFor(seconds, GalenPageActionWait.UntilType.GONE, locator); } public GalenActionsBuilder withCookies(String... cookies) { checkUsed(); GalenPageActionCookie a = new GalenPageActionCookie() .withCookies(cookies); a.setOriginalCommand("cookie " + Joiner.on("; ").join(cookies)); actions.add(a); return this; } public GalenActionsBuilder injectJavascript(String javascriptFilePath) { checkUsed(); GalenPageActionInjectJavascript a = new GalenPageActionInjectJavascript(javascriptFilePath); a.setOriginalCommand("inject " + javascriptFilePath); actions.add(a); return this; } public GalenActionsBuilder runJavascript(String javascriptFilePath) { checkUsed(); GalenPageActionRunJavascript a = new GalenPageActionRunJavascript(javascriptFilePath); actions.add(a); return this; } public GalenActionsBuilder runJavascript(String javascriptFilePath, String jsonArgs) { checkUsed(); GalenPageActionRunJavascript a = new GalenPageActionRunJavascript(javascriptFilePath) .withJsonArguments(jsonArgs); actions.add(a); return this; } public GalenActionsBuilder check(String specFile, List<String> tags) { checkUsed(); GalenPageActionCheck a = new GalenPageActionCheck() .withSpecs(Arrays.asList(specFile)) .withIncludedTags(tags); actions.add(a); return this; } public GalenActionsBuilder resize(int width, int height) { checkUsed(); GalenPageActionResize a = new GalenPageActionResize(width, height); a.setOriginalCommand("resize " + GalenUtils.formatScreenSize(new Dimension(width, height))); actions.add(a); return this; } public GalenActionsBuilder open(String url) { checkUsed(); GalenPageActionOpen a = new GalenPageActionOpen(url); a.setOriginalCommand("open " + url); actions.add(a); return this; } private void checkUsed() { if (built) throw new IllegalStateException("Incorrect builder usage error. build() method has been already called"); } public List<GalenPageAction> build() { built = true; return actions; } public GalenActionsBuilder scrollToElement(String locator) { String content = String.format("jQuery(\"%s\")[0].scrollIntoView(true);", locator); Properties properties = new Properties(); try (InputStream is = getClass().getResourceAsStream("/test.properties")){ properties.load(is); } catch (Exception e) { throw new RuntimeException("I/O Exception during loading configuration", e); } String workDirPath = properties.getProperty("work_dir"); String tempDirPath = workDirPath + "\\temp"; String auxJsFile = String.format("%s\\%s.js", tempDirPath, locator.hashCode()); File tempDir = new File(tempDirPath); tempDir.mkdirs(); try { PrintWriter writer = new PrintWriter(auxJsFile, "UTF-8"); writer.println(content); writer.close(); } catch (Exception e) { throw new RuntimeException("Exception during creating file", e); } injectJavascript(auxJsFile); return this; } }
åãã¹ãã®éå§æã«ãGalenã«ã¯ãæå®ãããã¬ã€ã¢ãŠãã®ç¯å²ããã©ã³ãã ãªèš±å¯ãäžããããŸãïŒgetRandomResolutionïŒDESKTOPïŒïŒïŒ
protected Dimension getRandomResolution(Dimension[] d) { return getRandomDimensionBetween(d[0], d[1]); } private Dimension getRandomDimensionBetween(Dimension d1, Dimension d2) { double k = Math.random(); int width = (int) (k * (Math.abs(d1.getWidth() - d2.getWidth()) + 1) + Math.min(d1.getWidth(), d2.getWidth())); int height = (int) (k * (Math.abs(d1.getHeight() - d2.getHeight()) + 1) + Math.min(d1.getHeight(), d2.getHeight())); return new Dimension(width, height); }
ãããŠå®éãèš±å¯ã®ç¯å²ã¯æ¬¡ã®åœ¢åŒã§èšå®ãããŸãã
public static final Dimension[] DESKTOP = {new Dimension(1920, 1080), new Dimension(1018, 1080)};
ãããã£ãŠãæå¹ãªç¯å²ãã解å床ãã©ã³ãã ã«éžæããåãã¿ã€ãã®ããŒãžã®ãµãã»ãããããã¹ãæžã¿ã®ããŒãžãéžæããããšã«ããã確ççãªããã»ã¹ã«ãªããŸãã èµ·åããã°ããã»ã©ãããŸããŸãªãã°ãèŠã€ãããŸãã ãã¹ãã«1ååæ Œãããšããã®ç¹å®ã®è§£å床ã®ãã®ç¹å®ã®ããŒãžãæå¹ã§ãããšããèšããŸããã ãããã500åã®å®è¡ãæåããåŸãã¬ã€ã¢ãŠãã®å€§éšåã¯å®è¡å¯èœã§ãããšäž»åŒµã§ããŸãã ã500件ã®æåããææ©çãªè©äŸ¡ã§ãããšããäºçŽãããã«è¡ããŸããããã§ã¯ãã³ã³ãã³ããšåçã®ããŒãžæ°ã確èªããå¿ èŠããããŸãã
ã©ã³ãã 解å床ã§å®è¡ãããšããã«ææãäžãããåºå®è§£å床ã§ãã¹ããå®è¡ãããšãã«èŠéããŠãããšæãããèå³æ·±ããã°ãããã«æããã«ãªããŸããã
ã¬ã·ãããŒãžããã¹ãããäŸã§ããã®ã¢ãããŒããã©ã®ããã«åœ¹ç«ã€ããæ€èšããŠãã ããã
ã¬ã·ãããŒãžã®ã¯ã€ã€ãã¬ãŒã ãã¹ãã¯ã768pxã1017pxã®è§£å床ç¯å²ïŒãã¥ãŒããŒãå¹ ïŒã§å®è¡ãããŸãã ããšãã°ã次ã®ããŒãžãã芧ãã ããïŒ www.washingtonpost.com/pb/recipes/maple-banana-frozen-yogurt/14143
Laptop layout'aïŒ1017pxããã³768pxïŒã®ãã³ãããŒã¯ãã¹ãã§ã¯ãšã©ãŒã¯çºçããŸããã§ããã
ãã ããã©ã³ãã ãªè§£å床ã§ãã¹ããå®è¡ãå§ããåŸãçŽååã®ã±ãŒã¹ã§ãã¹ãã倱æããã¹ã¯ãªãŒã³ã·ã§ããã§ã¯ãå³ã®åã®ãããã¯ãã¡ã€ã³ã³ã³ãã³ãã®äžã«å¿ã³èŸŒãã§ããããšã瀺ãããŸããã
æ£ããèŠè§£ïŒ
ã泚æ å šäœå
é衚瀺ã®ããã¹ã
å£ããã¬ã€ã¢ãŠãïŒ
ã泚æ å šäœå
é衚瀺ã®ããã¹ã
ã¹ã¯ãªãŒã³ã·ã§ããããŒã¹ã®ãã¹ãæ¹æ³
èšäºã«è§ŠçºãããŠãã¹ã¯ãªãŒã³ã·ã§ããããŒã¹ã®ãã¹ãæ¹æ³ã䜿çšããããšã«ããŸããã ãšããã§ãã¬ã€ã¢ãŠãããã¹ãããããã«ãæåã¯ãã®ã¡ãœããã«äŸåããŠããŸããã ã€ãŸã ããŒãžã®ãã«ãµã€ãºã®ã¹ã¯ãªãŒã³ã·ã§ãããäºåã«æºåãããã¢ãã«ãšæ¯èŒããæœåšçã«å€åãããã¹ãŠã®èŠçŽ ãã¹ã¿ãã«çœ®ãæãããšããèãããããŸããïŒäºåã«éžæãããä»»æã®ç»åãã¹ã¿ããšããŠååŸãããŸãïŒã ãããã®èŠçŽ ã«ã¯ãåçããã©ãã·ã¥åºåãããã¹ããå«ãŸããŸãã ãã®ã¢ã€ãã¢ã¯äž»ã«ãããŒãžã«åçã«ããŒããããå€ãã®ãããã¯ãå«ãŸããŠãããããã¹ã¯ãªãŒã³ã·ã§ããã®ç©çç寞æ³ãšãããã¯ã®å Žæããã¹ãã®å®è¡ããå®è¡ã«å€æŽãããããã«å€±æããŸããã ãŸããChromeã¯ãã«ãµã€ãºã®ã¹ã¯ãªãŒã³ã·ã§ãããæ®ãæ©èœããã°ãã倱ãããããå€ãã®åé¡ãåŒãèµ·ãããŸããã
ã¹ã¯ãªãŒã³ã·ã§ããããŒã¹ã®ãã¹ãã¯ã衚瀺ãéèŠãªããŒãžäžã®åã ã®èŠçŽ ãšãããã¯ããã§ãã¯ããããã«ãªããŸãããæ©èœãã¹ããŸãã¯ã¬ã¬ã³ãã¹ãã䜿çšãããã§ãã¯ã¯å°é£ãŸãã¯äžå¯èœã§ãã
äŸïŒ
washingtonpost.comã®ã¡ã€ã³ããŒãžïŒå·ŠïŒã®MostReadãããã¯ãšããã®ãããã¯ã®ã¹ã¯ãªãŒã³ã·ã§ãããæ¯èŒããã¢ãã«ïŒå³ïŒã§ãã
ãã¹ãã³ãŒãã¯æ¬¡ã®ããã«ãªããŸãã
@Test(groups = { "ScreenshotBased" }) @WebTest("Verifies that 'Post Most' block is displayed properly") public void testMakeupForPostMost() { HomePage page = new HomePage().open(); page.preparePostMostForScreenshot(); screenshotHelper.shootAndVerify(page, page.thePostMost, "_thePostMost"); }
ã¹ã¯ãªãŒã³ã·ã§ããã®ä¿åã«ã¯ã次ã®ãã£ã¬ã¯ããªæ§é ã䜿çšãããŸãã/models/HomePage/firefox/HomePage_thePostMost.png
ãããããããããã«ãããŸããŸãªãã©ãŠã¶ãŒã«ã€ããŠãå¿ èŠãªãããã¯ã®ã¢ãã«ã¹ã¯ãªãŒã³ã·ã§ãããååŸãããŸãã
shootAndVerifyïŒïŒã¡ãœããã¯ãéä¿¡ãããããŒãžã®ã¯ã©ã¹ãšãã¹ããå®è¡ãããŠãããã©ãŠã¶ãŒã®ååã«ãã£ãŠã¢ãã«ãžã®ãã¹ãæ€çŽ¢ããŸãã
å ã«èŠãŠã¿ãŸããã-ããã¯éåžžã«ããŸãæ©èœããŸãããããŠããã¹ãŠããŸã å®å šã«ãããã°ãããŠããªããšããèŠåã§ããã»ã¹ã®ããã€ãã®è©³çŽ°ã説æããŸãã
å€æããããã«ãå¿ èŠãªãããã¯ã®åçã¯ã次ã®ãããªå€ãã®èŠå ã«äŸåããå¯èœæ§ããããŸãã
- ãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã®ããŒãžã§ã³
- ãªãã¬ãŒãã£ã³ã°ã·ã¹ãã ã®ããŒã
- ãã©ãŠã¶ãšãã®ããŒãžã§ã³
- ããŸããŸãªãã©ã³ãã¹ã ãŒãžã³ã°ãªãã·ã§ã³ãšããŒããŠã§ã¢ã¢ã¯ã»ã©ã¬ãŒã·ã§ã³ã
æåã®åé¡ã¯ãæ®åœ±ãããã¹ã¯ãªãŒã³ã·ã§ããã®ãµã€ãºãOSãšãã©ãŠã¶ã®èšå®ã«ãã£ãŠç°ãªãããšã§ããã ãããã¯ã®ãµã€ãºãããã³çµæãšããŠã¹ã¯ãªãŒã³ã·ã§ãããåãã«ããã«ã¯ãäžå®ã®ãµã€ãºã§ãã©ãŠã¶ãŒãå®è¡ããå¿ èŠããããŸãã é©åãªWebãã©ã€ããŒã¡ãœããã䜿çšããŠããã©ãŠã¶ãŒãŠã£ã³ããŠã®ãµã€ãºãå€æŽã§ããŸãïŒdriver.manageïŒïŒãWindowïŒïŒãSetSizeïŒrequiredSizeïŒã ãã ãããã®æ¹æ³ã§ãå¿ èŠãªè¡šç€ºé åïŒãã¥ãŒããŒãïŒã®ãµã€ãºã§ã¯ãªãããŠã£ã³ããŠã®ãµã€ãºãèšå®ããŸãã ã¡ãªã¿ã«ãåçŽã¹ã¯ããŒã«ããŒã¯ãã¥ãŒããŒãã®ãµã€ãºã«ã圱é¿ãããã®å€ªãããŠã£ã³ããŠã®ããŒãã«äŸåããããããããèæ ®ããå¿ èŠããããŸãã åé¡ã®è§£æ±ºçã¯ãæå®ããã寞æ³ã«ãã¥ãŒããŒãã®ãµã€ãºã調æŽãããã£ãªãã¬ãŒã·ã§ã³æ¹æ³ã§ããã æåã®ãã¹ããéå§ããåŸããŠã£ã³ããŠãµã€ãºã®å¹ ãšãã¥ãŒããŒãã®å¹ ã®å·®ã¯ç¹å¥ãªãã©ã¡ãŒã¿ãŒã«ä¿åããã以éã®èµ·åæã«åå©çšãããŸãã
ç§ãã¡ãééãã2çªç®ã®åé¡ã¯ãã¢ã³ããšã€ãªã¢ã·ã³ã°ãªãã·ã§ã³ã«ãããã©ãŠã¶ãŒã§ã®ãã©ã³ãã®ç°ãªã衚瀺ã§ããã 次ã®ãããªããŸããŸãªãã©ãŠã¶èšå®ãã€ã³ã¹ããŒã«ããŠãåé¡ã解決ããããšããŸããã
layers.acceleration.disabled
gfx.font_rendering.cleartype_params.rendering_mode
gfx.direct2d.disabled
ããããæ®å¿µãªãããããã¯åœ¹ã«ç«ã¡ãŸããã§ããã
ããã«ãã¹ã¯ãªãŒã³ã·ã§ãããImageMagickãšæ¯èŒããããã«ãfuzzãªã©ã®ãã©ã¡ãŒã¿ãŒã䜿çšããŠãã¹ã¯ãªãŒã³ã·ã§ããéã®å¯èœãªæ倧差ãèšå®ããŸãã
ãã®ãã©ã¡ãŒã¿ãŒãè©ŠããŠããã®åé¡ã解決ããããšããŸããã å€æ°ã®ããã¹ããååšãããšããäºå®ã®ããã«ãããŸããŸãªãã¯ã»ã«ã®æ°ãéåžžã«å€§ãããããå°ããªãã¡ãºä¿æ°ã¯åé¡ã解決ããŸããã§ããããŸããä¿æ°ã倧ãããšããããã¯å ã®ããã€ãã®èŠçŽ ããªããŠããã¹ãã®åæ Œã«åœ±é¿ããããã°ãèŠéãå¯èœæ§ããããŸããã
解決çã¯ããã¹ããå®è¡ããããã¹ãŠã®ä»®æ³ãã·ã³ã§ããŸããŸãªãã©ãŠã¶ãŒã®ãã¹ãŠã®èšå®ãè€è£œãããªãã¬ãŒãã£ã³ã°ã·ã¹ãã èªäœã®èšå®ãè€è£œããããšã§ããã
ããšãã°ãç»åã®1ã€ãããŒããããªãã£ããœãŒã·ã£ã«ãã¿ã³ã®ãããã¯ããã§ãã¯ãããã¹ãã
ã¬ããŒãã§ã¯æ¬¡ã®ãªã³ã¯ã䜿çšã§ããŸãã
ã¢ãã«ç»å
ãã¹ããããã¯ã®ã¹ã¯ãªãŒã³ã·ã§ããïŒ
ãããã®2ã€ã®ç»åãæ¯èŒããçµæïŒ
CommandExceptionã¯ãæ¯èŒãããç»åã251pxç°ãªãããšã瀺ããŠããŸãã
ã¹ã¯ãªãŒã³ã·ã§ããã®ãµã€ãºãäžèŽããªãç¶æ³ããããŸãã ãã®å Žåã次ã®ã¬ããŒããåãåããŸãã
æªç¥ã®çç±ã§ããã¹ããããã¯å ã®èŠçŽ ããããã«åã£ãŠããå ŽåããããŸãã ãã®ãããªå Žåã1ã€ã®ã¢ãã«ãšæ¯èŒããã®ã§ã¯ãªãããã¹ã¯ã«é©ããã¢ãã«ã®ã°ã«ãŒããšæ¯èŒããŸãã HomePage_thePostMost.pngãHomePage_thePostMostïŒ1ïŒ.pngãšããååã®thePostMostãããã¯ã®è€æ°ã®ã¢ãã«ãäœæã§ãããã¹ãŠã®ã¢ãã«ãæå¹ã§ãããšèŠãªããŸãã 幞ããªããšã«ããã®ãããªãªãã·ã§ã³ã®æ°ã¯æéã§ãããéåžžã¯2以äžã§ãã
æè¡çåŽé¢
åè¿°ã®ããã«ããã¹ããJavaãMavenãTestNGãSeleniumãGalen Frameworkã®äœæãšå®è¡ã«ã¯ãã¯ãããžãŒã¹ã¿ãã¯ã䜿çšãããŸãã ããã«ããã¹ãçµæã¯ã°ã©ãã¡ã€ãã«éä¿¡ãããŸãã ãã¹ãã¯ãJenkins CISã䜿çšããŠçŽæ¥å®è¡ãããŸãã ãã®ãããªã»ãããéžæãããçç±ã«ã€ããŠã¯è©³ãã説æããŸããã ããããã¹ãŠçžäºæ¥ç¶ãããŠããæ¹æ³ãç°¡åã«èª¬æããŸãã
Selenium Gridã¯ãã°ãªããããŒããå®è¡ãããŠããWindows 7ãåãã4ã€ã®ä»®æ³ãã·ã³ãšããããå®è¡ãããŠããLinuxãã·ã³ã«ããŒã«ã«ã§å±éãããŸãã åããŒãã§äœ¿çšå¯èœãªFirefoxããã³Chromeãã©ãŠã¶ã®3ã€ã®ã€ã³ã¹ã¿ã³ã¹ããããŸãã ããã«ããžã§ã³ãã³ã¹ãšã°ã©ãã¡ã€ããLinuxãã·ã³ã«å±éãããŸãã Galenãã¹ãã¯ãTestNGãšã®çµ±åãéããŠäžè¬çãªãã¹ãå®è¡ã§å®è¡ãããŸãã ãããè¡ãããã«ãjav Galen APIã䜿çšã§ããé©åãªã¯ã©ã¹ãäœæãããŸããã TestNGãšã¬ã¬ã³ã®çžäºäœçšãå®è£ ããéã«ãã¬ã¬ã³éçºè ãšã®çžäºäœçšã«ããããã«è§£æ±ºãããããã€ãã®åé¡ããããŸããã æ¹éé±éçºè èªèº«ãåãã§ååããå®æçã«ãã®ããŒã«ã®ã¢ããããŒãããªãªãŒã¹ããŸããããã«ãããæ©èœãæ¡åŒµãããããã«äŸ¿å©ã«ãªããŸãã 圌èªèº«ã¯ãã¬ã¬ã³ãšTestNGã®çµ±åã«é¢ããããã¥ã¡ã³ããæžãäºå®ã§ãã
æ©èœãã¬ã¬ã³ãããã³ã¹ã¯ãªãŒã³ã·ã§ããããŒã¹ã®ãã¹ãã¯ãTestã¢ãããŒã·ã§ã³ã«å²ãåœãŠãããé©åãªã°ã«ãŒããã©ã¡ãŒã¿ãŒã䜿çšããŠåé¢ãããåå¥ã«èµ·åãããå¯èœæ§ããããŸãã
çµè«
ã¹ã¯ãªãŒã³ã·ã§ããã®æ¯èŒãšGalen Frameworkã䜿çšãããã¹ãã®äž¡æ¹ã®æ¹æ³ã¯ãããŒãžã¬ã€ã¢ãŠãã®ãã¹ãã«é©çšã§ããŸãã ãããã¯äºãã«ããŸãè£å®ãåãã ã¹ã¯ãªãŒã³ã·ã§ãããæ¯èŒããæ¹æ³ã¯ããœãŒã·ã£ã«ãããã¯ãŒã¯ã®å ±æããã«ãããããŒã®ã¡ã€ã³ã¡ãã¥ãŒãªã©ãåäžã®èŠçŽ ãŸãã¯ãããã¯ã®è¡šç€ºããã¹ãããå¿ èŠãããå Žåã«ããé©ããŠããŸãã ãããã¯ã«ã¯ããã®äžã«å€ãã®ã¢ã€ã³ã³ãå«ããããšãã§ããŸãããããã®ã¢ã€ã³ã³ã¯ãä»ã®ã¢ã€ã³ã³ãèŠçŽ ã®äžã«é 眮ããããçžå¯Ÿçãªäœçœ®ãèšå®ãããã§ããŸãã
Galenã䜿çšããŠããããã¹ãŠã®å°ããªç¬éãèšè¿°ããã®ã¯ããªãæéãããããŸãããåãã©ãŠã¶ãŒã®1ã€ã®ã¹ã¯ãªãŒã³ã·ã§ããã¯ãã®åé¡ã解決ããã¹ã¯ãªãŒã³ã·ã§ããã®æ¯èŒã§ã¯ãä»æ§ã説æãããšãã«äœããèŠéãå¯èœæ§ããããªãã·ã§ã³ãé€å€ããŸãã 次ã«ãGalenã¯ãããã¯ã®çžå¯Ÿçãªé 眮ã«å¯ŸåŠããããããŒãšãã®äžã®åºå®ããã¹ãããã§ãã¯ããŸãã ããšãã°ãæ å ±ããŒã¿ã«ãªã©ãæ©èœããžãã¯ãèªã¿èŸŒãŸããŠããªãåãã¿ã€ãã®ãã³ãã¬ãŒãããŒãžã§ã¬ã€ã¢ãŠãããã¹ãããå¿ èŠãããå Žåããã®ã±ãŒã¹ã®ããã«ããµã€ãã®ã»ãšãã©ãã¹ãŠã®ããŒãžã«èš±å¯ãªãã¢ã¯ã»ã¹ã§ããå ŽåããŸãã¯ä»ã®ãŠãŒã¶ãŒã¢ã¯ã·ã§ã³ãå®è¡ããå Žåã«åœ¹ç«ã¡ãŸãã ããã«ãGalenã¯é©å¿åã¢ããªã±ãŒã·ã§ã³ã¬ã€ã¢ãŠãã®ã¯ãã¹ãã©ãŠã¶ãŒãã¹ããããŸã解決ããŸãã