IE AutoTester ã§ï¼UIã®å帰ãã¹ããå®å ¨èªåå
ãã¹ãä»æ§ãæ¸ãã°ï¼ä»æ§æ¸èªèº«ããã¹ãï¼ãã©ã¦ã¶æä½ï¼ãèªåã§ãã£ã¦ãããã
Excelã®ã·ã¼ãä¸ã«ï¼ä¸è¨ã®ããã«è¨è¿°ããã
IEèµ·å éã http://www.yahoo.co.jp/ åå¨å¤å® srchtxt åå¨å¤å® srchbtn å ¥å srchtxt hogeraccho ã¯ãªãã¯ãã¦å¾ æ© srchbtn
ããï¼ããã ãã§ã¯ãªãã
- ãã¹ãä»æ§æ¸ã«ï¼è©¦é¨ã®çµæãèªåã§è¨é²ãã¦ãããã
- Seleniumã§å¯è½ãªé常ã®DOMæä½ã«å ãã¦ï¼
- ãã¦ã¹ã®ãã©ãã°ãããããï¼
- ãã¡ã¤ã«ã®ã¢ãããã¼ãã»ãã¦ã³ãã¼ãã¨ãã£ãï¼è¾¼ã¿å ¥ã£ãUIã®ãã¹ããèªååã§ããã
- ã¯ãã¹ãã¡ã¤ã³ã§ãã¹ãã§ãããï¼ãã¹ã対象ã®ãµã¼ãä¸ã«ï¼ãã¹ãç¨ã®ãã¡ã¤ã«ä¸è¦ï¼
ãExcelã§ãã¹ãä»æ§æ¸ãæ¸ããã¨ããã®ã¯Exceleniumã¨åãããæ¹ã ãï¼ä¸è¨ã®ããã«Seleniumã§ä¸å¯è½ã ã£ãç¹ãè£ã£ã¦ããã
ãããï¼ä»åç´¹ä»ãã IE AutoTester ã¨ãããã¼ã«ã
åä½ãã£ããã£ï¼
- Excelã®ã·ã¼ãã®å·¦å´ã§ï¼æä½ã®ã¹ããããæ¸ãã
- ããã¨å³å´ã§ï¼ãã¹ãä»æ§æ¸ã¨ãã¦ã®æç« ããªã¢ã«ã¿ã¤ã ã§çæããããExceleniumã¨åãã
ããã§ãå
¨ã·ã¼ããå®è¡ãã®ãã¿ã³ãæ¼ãã¨ï¼ã·ã¼ãã«æ¸ãã¦ããéãï¼ãã©ã¦ã¶ãèªåçã«åãã
- ãã¦ã¹ã®ãã©ãã°ãããããèªåã§ãã¹ããã¦ãã風æ¯ã
- ãã¹ãããªããï¼ãå®è¡ãã°ãã®æ¬ã«çµæãæ¸ãè¾¼ã¾ãã¦ããã
- OKã®ã»ã«ã¯ç·ã«ï¼NGã¯èµ¤ã«ãªãã
- NGæ°ã¯ã·ã¼ãä¸é¨ã§éè¨ãããã
ãã¹ãã ãã§ãªãï¼ãã©ã¦ã¶ã®æ°è»½ãªèªåæä½ã«ãå©ç¨ã§ããã ããã
IE AutoTesterããã¦ã³ãã¼ã
以ä¸ã¯ï¼ãµã³ãã«ã¨ä½¿ãæ¹ã
ä¸ã®å§ç¸®ãã¡ã¤ã«ã解åããã¨ï¼ãIEAutoTester.xlsãã¨ããã¨ã¯ã»ã«ãã¡ã¤ã«ãããã
ãããéãéï¼Excelã®è¨å®ãå¿ è¦ãªã®ã§æ¸ã¾ãã¦ããã
(Excel2003ã®å ´å)
ãã¼ã«ï¼ãã¯ãï¼ã»ãã¥ãªãã£ï¼ä¿¡é ¼ã§ããçºè¡å ï¼Visual Basic ããã¸ã§ã¯ãã¸ã®ã¢ã¯ã»ã¹ãä¿¡é ¼ãããããªã³
(Excel2007ã®å ´å)
ãªãã³ã®ãéçºãã¿ãï¼ãã¯ãã®ã»ãã¥ãªãã£ï¼VBAããã¸ã§ã¯ããªãã¸ã§ã¯ãã¢ãã«ã¸ã®ã¢ã¯ã»ã¹ãä¿¡é ¼ãã
http://support.microsoft.com/kb/28283...
â»ãããã°ã©ãã³ã°ã«ããVisual Basicããã¸ã§ã¯ãã¸ã®ã¢ã¯ã»ã¹ã¯ä¿¡é ¼æ§ã«æ¬ ãã¾ããã¨ããã¨ã©ã¼ã¡ãã»ã¼ã¸ãåºãªãããã«ãªãã
ï¼ï¼ï¼å°å ¥
å°å ¥ã«å¿ è¦ãªæé ã¯ï¼ï¼ã¤ã ãã
ï¼çªç®ã«ï¼
ä¸è¨ãµã¤ããããUWSCãã¨ããWindowsã¹ã¯ãªããã¨ã³ã¸ã³ããã¦ã³ãã¼ããï¼ããªã¼çï¼
http://www.uwsc.info/download.html
é©å½ãªãã©ã«ãã«è§£åã
ï¼çªç®ã«ï¼
å
ã»ã©ãã¦ã³ãã¼ãããIEAutoTester.xlsã¨åããã©ã«ãã«å梱ããã¦ãããIEManipulation.uwsããï¼uwsc.exeã¨åããã©ã«ãã«è¨ç½®ã
ï¼çªç®ã«ï¼
ä¸ã§å
¥æããã¨ã¯ã»ã«ã®ï¼ãã¼ã¸ç®ï¼ãåæè¨å®ãã·ã¼ãã«
- UWSC.exeè¨ç½®ãã¹
- ã¹ã¯ãªããè¨ç½®ãã¹
ã¨ãã¦ï¼uwsc.exeã®åå¨ãããã¹ãè¨å ¥ã
ããã ãã
ï¼ï¼ï¼åä½
åããã¦ã¿ããã
ãã¹ãã±ã¼ã¹ã®ã·ã¼ãä¸ã§ãå ¨ã·ã¼ãå®è¡ï¼ãã°ãªãï¼ãã¨ãããã¿ã³ãæ¼ä¸ã
IEãåãåºãã
- Yahooã§æ¤ç´¢
- ãã¦ã¹ã§ä¸¦ã³æ¿ã
ã®ï¼ãµã³ãã«ãå®è¡ãããã
ãã°ãªããªã®ã§ï¼çµæã¯è¨é²ãããªãã
ï¼ï¼ï¼ãã°ãè¨é²ãããã
ä»åº¦ã¯ï¼ãå ¨ã·ã¼ãå®è¡ï¼ãã°ããï¼ãã¨ãããã¿ã³ãæ¼ä¸ã
ãã©ã¦ã¶ã®åä½ãçµããã¨ï¼ããã°ãé²è¦§ãã¾ããï¼ãã¨èãããã
ãã¯ãããæ¼ãã¨ï¼ãã¹ãä»æ§æ¸ãéãã
å³ã®æ¹ãè¦ãã¨ï¼ãOKãã¨æ¸ãã¦ããã¯ãã ã
ç°¡åãªä½¿ãæ¹ã®èª¬æã¯ããã¾ã§ã
ããï¼åä½ã«ããªã¨ã¼ã·ã§ã³ãã»ããã£ããã»ã»ã»
- ãã³ãã³ãä¸è¦§ãã·ã¼ãã®å 容ãå¢ããã
- ãUã³ã¼ããã³ãã³ãã§ï¼UWSCã³ã¼ããåãè¾¼ãã
- ãJSã³ã¼ããã³ãã³ãã§ï¼JavaScriptã³ãã³ããåãè¾¼ãã
ãªã©ï¼æ¡å¼µã®ããããããã
以ä¸ã¯åä½åçã
è£å´ã§ãã£ã¦ãããã¨
å®è¡å¯è½ãªã³ãã³ãã«ã¤ãã¦ã¯ï¼ãã³ãã³ãä¸è¦§ãã®ã·ã¼ããè¦ãã°ãããã
ãããã®ã³ãã³ãã®å®è£ ã¯ï¼IEManipulation.uwsã®ä¸èº«ãè¦ãã°ãããã
ãã©ã¦ã¶ã®èªåãã¹ãä¸ã«ï¼ãã¹ãçµæãExcelã«è¨é²ãããï¼UWSCã§IEãèªåæä½ããã©ã¤ãã©ãª 1.3ï¼
http://language-and-engineering.hatenablog.jp/entry/20090918/p1
ãµã³ãã«ã¨åããï¼Excelä¸ã§ä¸è¨ã®ãããªã³ãã³ããè¨è¿°ããã¨ããã
IEèµ·å éã http://www.yahoo.co.jp/ åå¨å¤å® srchtxt åå¨å¤å® srchbtn å ¥å srchtxt hogeraccho ã¯ãªãã¯ãã¦å¾ æ© srchbtn
ãå®è¡ï¼ãã°ãªãï¼ãã®ãã¿ã³ãæ¼ãã¨ï¼ãã¯ãã§ä¸è¨ã®ãããªuwsã¹ã¯ãªãããçæããã»ã»ã»
// ã·ã¹ãã å:ãã¹ãè¨è¿°ã®ãµã³ãã« // æ©è½å¤§åºå:åºæ¬æ©è½ // â»ãã®ãã¡ã¤ã«ãç´æ¥ç·¨éããªãã§ãã ããã call .\IEManipulation.uws // ---------- ã·ã¼ãçªå·:1ï¼æ©è½å°åºå:01_ãµã¼ãã¨ã³ã¸ã³æä½ ---------- // æ¤ç´¢ _ie = IE.new(); IE.show( _ie ) IE.jump( _ie, "http://www.yahoo.co.jp/") IE.assert_element_present( _ie, "srchtxt" ) IE.assert_element_present( _ie, "srchbtn" ) IE.type( _ie, "srchtxt", "hogeraccho" ) IE.click_and_wait( _ie, "srchbtn" ) // çµäºå¦ç IE.save_and_close_logfile() IE.end_manipulation()
ããã¦ï¼ãã®ã¹ã¯ãªãããuwsc.exeã«æ¸¡ãããã
Excelãããã£ã¦ãã人ããã¯ï¼ã²ã¨ãã§ã«IEãåãåºãããã«è¦ããã
ãå®è¡ï¼ãã°ããï¼ãã®ãã¿ã³ãæ¼ããå ´åã¯ã©ããã
ä¸è¨ã®ãããªuwsã¹ã¯ãªãããçæãããã
// ã·ã¹ãã å:ãã¹ãè¨è¿°ã®ãµã³ãã« // æ©è½å¤§åºå:åºæ¬æ©è½ // â»ãã®ãã¡ã¤ã«ãç´æ¥ç·¨éããªãã§ãã ããã call .\IEManipulation.uws IE.use_log(True) Sleep(3) IE.open_xls_as_logfile("D:\temp\excel_ie\IEAutoTester\IEAutoTester.xls") // ---------- ã·ã¼ãçªå·:1ï¼æ©è½å°åºå:01_ãµã¼ãã¨ã³ã¸ã³æä½ ---------- // æ¤ç´¢ IE.set_pgcount( "01_ãµã¼ãã¨ã³ã¸ã³æä½", 11, 11 ) _ie = IE.new(); IE.show( _ie ) IE.set_pgcount( "01_ãµã¼ãã¨ã³ã¸ã³æä½", 12, 11 ) IE.jump( _ie, "http://www.yahoo.co.jp/") IE.set_pgcount( "01_ãµã¼ãã¨ã³ã¸ã³æä½", 14, 11 ) IE.assert_element_present( _ie, "srchtxt" ) IE.set_pgcount( "01_ãµã¼ãã¨ã³ã¸ã³æä½", 15, 11 ) IE.assert_element_present( _ie, "srchbtn" ) IE.set_pgcount( "01_ãµã¼ãã¨ã³ã¸ã³æä½", 17, 11 ) IE.type( _ie, "srchtxt", "hogeraccho" ) IE.set_pgcount( "01_ãµã¼ãã¨ã³ã¸ã³æä½", 18, 11 ) IE.click_and_wait( _ie, "srchbtn" ) // çµäºå¦ç IE.save_and_close_logfile() IE.end_manipulation()
ãã°ãªãã®å ´åã¨æ¯ã¹ã¦ï¼IE.set_pgcountã³ãã³ãã®åã ãï¼è¡æ°ãå¢ããã
ãã®ã³ãã³ãã¯ï¼ãã°ã®è¨é²ä½ç½®ãæå®ãã¦ããããã¨ãã°
IE.set_pgcount( "01_ãµã¼ãã¨ã³ã¸ã³æä½", 14, 11 )
ã¯ï¼æ¬¡ã®æ¤è¨¼ã³ãã³ãã®ãã°è¨é²ä½ç½®ãï¼ãã¹ãä»æ§æ¸ã®ã01_ãµã¼ãã¨ã³ã¸ã³æä½ãã¨ããã·ã¼ãã®14è¡11åç®ã«æå®ãã¦ããã
ã ããï¼ç¶ãè¡ã«ãã
IE.assert_element_present( _ie, "srchtxt" )
ã®çµæã¯ï¼ãã®ä½ç½®ã«è¨é²ãããã
â»pgcountã¨ããã®ã¯ãããã°ã©ã ã«ã¦ã³ã¿ãã®ã¤ããã
ãªãï¼VBAãã¯ã㯠IEAutoTesterCore.basã«è¨è¿°ããã¦ããï¼ è¤æ°ã®ããã¯ããå ±æã§ããã
ä¸è¨ã®ææ³ã使ã£ã¦ããã
Excel VBAã®ãã¯ããï¼è¤æ°ã®ããã¯ããå©ç¨ããæ¹æ³ ï¼æ¨æºã¢ã¸ã¥ã¼ã«ãããã¯ã®å¤é¨ã§ç®¡çãã¦ï¼å ±éã©ã¤ãã©ãªã¨ãã¦èªã¿è¾¼ã¿ï¼
http://language-and-engineering.hatenablog.jp/entry/20090731/p1
æ¯è¼
Selenium / Excelenium ã¨ï¼ãã®IE AutoTester ãæ¯è¼ããã
ã | Selenium/Excelenium | IE AutoTester |
---|---|---|
Excelã«æä½æé ãæ¸ãã ã | â | â |
ãã¹ãã«JavaScriptãåãè¾¼ã¿å¯è½ | â | â |
ã¯ãã¹ãã¡ã¤ã³ | à | â |
ãã¹ãçµæãç´æ¥è¨é² | à | â |
ãã¼ã«ã«ç°å¢ï¼ãã¡ã¤ã«çï¼ã®æä½ | à | â |
è¦ç´ ã®ãã©ãã°ãããã | à | â |
ãã¡ã¤ã«ã®ã¢ãããã¼ã | à | â |
ãã¡ã¤ã«ã®ãã¦ã³ãã¼ã | à | â |
ã¯ãã¹ãã©ã¦ã¶ | â | Ãï¼ååã®éãï¼IEã®ã¿ï¼ |
ãã¹ãã¡ã½ããã®å å®åº¦ | â | â³ï¼å¢ãããï¼ |
XPathæ¨æºãµãã¼ã | â | à |
æ¬ãã¼ã«ã¯ï¼Exceleniumã®æ¬ ç¹ãè£ãç®çã§ä½æãããã
- åºæ¬ã¯Exceleniumã§
- è¤éãªUIã®é¨åã¯IE AutoTesterã§
ããããï¼å帰ãã¹ããçµãã¨ããã ããã
ã¾ãèå³æ·±ãç¹ã¨ãã¦ï¼Exceleniumã¨æ¬ãã¼ã«ã®éã§ï¼ãExcelä»æ§æ¸ããã®ã¹ã¯ãªããçæããä¸è¬åãããã
両ãã¼ã«ã«ããã¦ï¼ç°ãªã£ã¦ããã®ã¯
- ã³ãã³ãã®ã»ããï¼ãã³ãã³ãä¸è¦§ãã·ã¼ãã®å 容ï¼
- çæç©ã渡ãã¦è§£éãããè¡å
ã ãã
ãã®å½¢å¼ãæµç¨ããã°ï¼éçºããã¸ã§ã¯ãå
ã®ãã¾ãã¾ãªæé ãèªååã§ãããã¨ã ããã
è£è¶³ï¼ãã¡ã¤ã«ã¢ãããã¼ãã®ãã¹ã
ãµã³ãã«ã®ï¼ã·ã¼ãç®ã«ã¯ï¼ããã¡ã¤ã«ã¢ãããã¼ããã¨ããå 容ãè¼ã£ã¦ããï¼ã³ã¡ã³ãã¢ã¦ãããã¦ããã
ãã®ã·ã¼ããåããããã®ãµã³ãã«ã¢ããªã±ã¼ã·ã§ã³ãæ²è¼ããã
Ruby on Railsã§ï¼ãã¡ã¤ã«ãã¢ãããã¼ãããç°¡åãªã³ã¼ãï¼
hoges_controller
require 'kconv' class HogesController < ApplicationController # ã¢ãããã¼ãç»é¢ def uptest end # ã¢ãããã¼ãå®è¡ã¢ã¯ã·ã§ã³ # http://rails.takeda-soft.jp/blog/show/51 def uptest_exec # éä¿¡ããã¦ãããã¡ã¤ã« file_obj = params[ "my_file" ] # ä¿åãã¹ãæ±ºå® @file_name = file_obj.original_filename save_path = Dir::pwd + "/public/" + get_platform_filename( @file_name ) # ç¾æç¹ã§ã®ã«ã¬ã³ããã£ã¬ã¯ããªã¯ï¼/appã®ä¸ã®é層 #raise Dir::pwd # ä¿å file_content = file_obj.read File.open( save_path, "wb"){ |f| f.write( file_content ) } end private # OSã«é©ãããã¡ã¤ã«åã«å¤æãã¾ãã # http://ruby-gnome2.sourceforge.jp/ja/hiki.cgi?libglade2-tut-create-src def get_platform_filename( filename ) if RUBY_PLATFORM.include?( "mswin32" ) # Windowsã®å ´åï¼ãã¡ã¤ã«åã®æåã³ã¼ãã¯SJIS return Kconv.tosjis( filename ) else # ãã®ä»ã¯UTF8 return Kconv.toutf8( filename ) end end end
uptest.rhtmlãï¼ã¢ãããã¼ãããããã®ãã©ã¼ã ï¼
<select id="hoge1"> <option>a</option> <option>b</option> </select> <br> <select id="hoge2"> <option value="1">a</option> <option value="2">b</option> </select> <br> <!-- ã¢ãããã¼ãã«é¢ä¿ã®ããé¨å --> <%= form_tag( { :action => "uptest_exec" }, :multipart => true ) %> ã¢ãããã¼ãããããã¡ã¤ã«ï¼ <%= file_field_tag( "my_file" ) %> <%= submit_tag( "éä¿¡", { :id => "commit_button" } ) %> <%= end_form_tag %>
uptest_exec.rhtml
<%= link_to "ãã¦ã³ãã¼ã", "/" + @file_name %>
ã¢ãããããã¡ã¤ã«ãRailsã®publicãã©ã«ãã«ç´æ¥ç½®ãã¦ããã¨ããï¼ä½ã¨ãå±éºãªæ§æã ãï¼ã¾ããã¹ãå®è¡ç¨ãªã®ã§OKã¨ããã
ãã¡ã¤ã«ã¢ãããã¼ãé¨åã®ãã¹ããåä½ãããããã«ã¯ï¼ãã¹ã¯ãããã«ãa.txtãã¨ãããã¡ã¤ã«ãä½æãã¦ãããã¨ã
é¢é£ããè¨äºï¼
UWSCã®ãã¯ãã§ï¼IEãèµ·åãã¦èªåæä½ãããµã³ãã«ã³ã¼ã
http://language-and-engineering.hatenablog.jp/entry/20140204/controlIeBrowser...
JScript / VBScript (WSH)ã§ï¼IEãèªåæä½ããã
http://language-and-engineering.hatenablog.jp/entry/20090713/p1
ãå®è¡å¯è½ããã¥ã¡ã³ãããæºããã¹ãæ§è³ªãâããã¹ãèªååãã¼ã«ãExceleniumãã§ä½¿ããã¦ããæè¡ãææ³
http://language-and-engineering.hatenablog.jp/entry/20101112/p1
ã