ãã©ã¦ã¶ã®èªåãã¹ãä¸ã«ï¼ãã¹ãçµæãExcelã«è¨é²ãããï¼UWSCã§IEãèªåæä½ããã©ã¤ãã©ãª 1.3ï¼
ä¸è¨ã®ã©ã¤ãã©ãªãæ¹è¯ããã
ãã©ã¦ã¶ä¸ã§ï¼ãã¦ã¹ã®ãã©ãã°ï¼ãããããèªååã§ããã¹ã¯ãªããï¼UWSCã§IEãèªåæä½ããã©ã¤ãã©ãª 1.2ï¼
http://d.hatena.ne.jp/language_and_engineering/20090826/p1ãã®æãã£ãæ©è½ï¼
- IEä¸ã§ã®DOMæä½
- IEä¸ã§ã®ä»»æã®JavaScriptå®è¡ã¨ï¼ãã®å®è¡çµæã®åå¾
- IEä¸ã§ã®ãã¡ã¤ã«ã®ã¢ãããã¼ãï¼ãã¦ã³ãã¼ã
- IEä¸ã§ã®DOMè¦ç´ ã®ãã©ãã°ãããã
- IEä¸ã§ã®ãã©ã¦ã¶ãã¹ãï¼assertionãå®è¡ï¼
ä»åã®è¿½å æ©è½:
- ãã©ã¦ã¶ãã¹ããå®è¡ããªããï¼ãã®å®è¡çµæãã°ãExcelã«è¨é²ãããã¨ãå¯è½ã«ã
ã»ã»ã»assertç³»ã®ã³ãã³ããå®è¡ããéã«ï¼
- çµæãOKãNGã
- 詳細ï¼å¤ãéã£ãå ´åã¯ç¾å®ã®å¤ããªãã ã£ãããªã©ï¼
- æå»
ãï¼æå®ããExcelãã¡ã¤ã«ã®å¥½ããªä½ç½®ã«è¨é²ã§ããã
以ä¸ãµã³ãã«ã³ã¼ãã
ãã°ãã¨ããªãå ´åï¼ãhoge1.uws
call .\IEManipulation.uws // æ°è¦IE _ie = IE.new(); IE.show( _ie ) // Yahoo㸠IE.jump( _ie, "http://www.yahoo.co.jp/") // è¦ç´ ãåå¨ãããã©ããããã¹ã IE.assert_element_present( _ie, "srchtxt" ) IE.assert_element_not_present( _ie, "hoge" ) // æ¤ç´¢ IE.type( _ie, "srchtxt", "hogeraccho" ) IE.click_and_wait( _ie, "srchbtn" ) // æååããã¹ã IE.assert_text( _ie, "ygmalogo", "Yahoo! JAPAN" ) //IE.assert_text( _ie, "ygmalogo", "ã»ã" ) // çµäº IE.end_manipulation() msgbox( "çµäºãã¾ããã" )
ãã°ãã¨ãå ´åï¼ãhoge2.uws
call .\IEManipulation.uws // ãã®ã³ã°ãæå¹ã«ãã IE.use_log( True ) IE.open_xls_as_logfile( "D:\temp\a.xls" ) // ä¿åå ãã¡ã¤ã« // æ°è¦IE _ie = IE.new(); IE.show( _ie ) // Yahoo㸠IE.jump( _ie, "http://www.yahoo.co.jp/") // è¦ç´ ãåå¨ãããã©ããããã¹ãï¼set_pgcountã§ï¼ãã°ã®è¨é²å ´æãè¨å®ãã¦ããï¼ IE.set_pgcount( "Sheet1", 1, 1 ) IE.assert_element_present( _ie, "srchtxt" ) IE.set_pgcount( "Sheet1", 2, 1 ) IE.assert_element_not_present( _ie, "hoge" ) // æ¤ç´¢ IE.type( _ie, "srchtxt", "hogeraccho" ) IE.click_and_wait( _ie, "srchbtn" ) // æååããã¹ã IE.set_pgcount( "Sheet1", 3, 1 ) IE.assert_text( _ie, "ygmalogo", "Yahoo! JAPAN" ) //IE.set_pgcount( "Sheet1", 4, 1 ) //IE.assert_text( _ie, "ygmalogo", "ã»ã" ) // ãã°ãã¡ã¤ã«ãä¿å IE.save_and_close_logfile() // çµäºï¼ãã°ãã¡ã¤ã«ãé²è¦§ãããã©ãã質åãããï¼ IE.end_manipulation()
UWSC.exeã«ããããã®ãã¡ã¤ã«ããã©ãã°ãããããã¦åä½ãéå§ããã
ãã°ã®ã¨ãæ¹ï¼
- use_log(True)ã§ãã®ã³ã°ãæå¹ã«ãªã
- open_xls_as_logfileã§ï¼ãã¹ãçµæä¿åå ã®Excelãã¡ã¤ã«ãæå®
- set_pgcountã§ï¼æ¬¡ã®assertionçµæãè¨é²ãããã·ã¼ãåã¨ï¼ã»ã«ã®è¡çªå·ï¼åçªå·ãæå®
- assertãå®è¡ããããã³ã«ï¼ãã®ã»ã«ï¼ããï¼ã¤å³ã¾ã§ã®ã»ã«ï¼ã«çµæãæ¸ãè¾¼ã¾ããã
- save_and_close_logfileã§ï¼ãã°ç¨ã®Excelãä¿å
- ãã®ã³ã°ãæå¹ãªãã°ï¼end_manipulationæã«ï¼ãã°ãé²è¦§ãããã©ããèãããã
èªåãã¹ãï¼èªåçµæè¨é²ã
ãã®ããã®ã©ã¤ãã©ãªï¼
IEManipulation.uws
// // IEãèªåæä½ããããã®ã©ã¤ãã©ãª ver 1.32 // // æ©è½ï¼ // ã»IEä¸ã§ã®DOMæä½ // ã»IEä¸ã§ã®ä»»æã®JavaScriptå®è¡ã¨ï¼ãã®å®è¡çµæã®åå¾ // ã»IEä¸ã§ã®ãã¡ã¤ã«ã®ã¢ãããã¼ãï¼ãã¦ã³ãã¼ã // ã»IEä¸ã§ã®DOMè¦ç´ ã®ãã©ãã°ãããã // ã»IEä¸ã§ã®ãã©ã¦ã¶ãã¹ãï¼assertionãå®è¡ï¼ãã¹ãçµæãã°ãExcelã«è¨é²ï¼ // // ãããï¼ // ã»1.31 wait_for_element_presentã®ãã°ãä¿®æ£ // ã»1.32 gidã¨jumpãå®å®å class IE // -------------------- å¶å¾¡ -------------------- // æ°è¦IEãªãã¸ã§ã¯ããä½æãã¦è¿ã function new() result = createOLEobj("InternetExplorer.Application") fend // èµ·åä¸ã®IEãè¦ããããã« procedure show( browser ) browser.visible = True // ä½ç½®èª¿æ´ wid = hndtoid( browser.hwnd ) acw( wid, 0, 0 ) // æ大å ctrlwin( wid, MAX ) // ãã¦ã¹ç¸å¯¾åº§æ¨ããã®ãã©ã¦ã¶åºæºã«è¨å® MouseOrg( wid ) pause( browser ) fend // IEããã¸ã¼ç¶æ ã®éå¾ ã¡ã¾ã procedure wait( browser ) repeat sleep( 0.1 ) until ( ! browser.busy ) and ( browser.readystate = 4 ) pause( browser ) fend // URLã«ã¸ã£ã³ã procedure jump( browser, url ) browser.navigate( url ) total_wait_sec = 0 loop_flag = True while loop_flag // èªã¿ãã¿å®äºãããï¼ ifb ( ! browser.busy ) and ( browser.readystate = 4 ) then loop_flag = False else sleep( 0.2 ) total_wait_sec = total_wait_sec + 0.2 endif // ã¿ã¤ã ã¢ã¦ããï¼ ifb total_wait_sec > 10 then // èªã¿è¾¼ã¿ãªãã browser.navigate( url ) total_wait_sec = 0 endif wend pause( browser ) fend // ãã¼ãº procedure pause( browser ) sleep( 0.2 ) fend // è¦ç´ ãåºç¾ããã¾ã§å¾ ã¡ã¾ã procedure wait_for_element_present( browser, dom_id, timeout_sec ) interval_sec = 0.2 total_wait_sec = 0 loop_flag = True while loop_flag // è¦ç´ ã¯ç¾ããã ifb is_element_present( browser, dom_id ) then // åºç¾ããã®ã§ã«ã¼ãçµäº loop_flag = false else // åºç¾ãã¦ããªãã®ã§ã¹ãªã¼ã sleep( interval_sec ) total_wait_sec = total_wait_sec + interval_sec endif // ã¿ã¤ã ã¢ã¦ãã ifb total_wait_sec > timeout_sec then msgbox( "element '" + dom_id + "' did not appear." ) end_manipulation() endif wend fend // è¦ç´ ãåå¨ãããã©ããå¤å® function is_element_present( browser, dom_id ) ifb ( browser.document = Nothing ) or ( browser.document.getElementById( dom_id ) = Nothing ) then result = False else result = True endif fend // IEã®æä½ã¹ã¯ãªãããçµäºãã¾ã procedure end_manipulation() ifb _use_log_flag = True then confirm_show_logging_result() endif exitexit fend // -------------------- DOMæä½ -------------------- // IDã渡ãããå ´åã¯DOMè¦ç´ ã«ãã¦è¿ãã¾ã function to_elem( browser, locator ) ifb VarType( locator ) = 8 then // å¤æ°ã®åãæååã®å ´åã¯DOM IDã¨ã¿ãªã result = gid( browser, locator ) else // ãã以å¤ã®å ´åã¯ã¹ã«ã¼ result = locator endif // VarTypeã®ãã«ãï¼http://msdn.microsoft.com/ja-jp/library/cc392346.aspx fend // $ function gid( browser, dom_id ) total_wait_sec = 0 elem = Nothing while total_wait_sec < 10 // è¦ç´ ã¯ãããï¼ ifb is_element_present( browser, dom_id ) then elem = browser.document.getElementById( dom_id ) break else // ç¡ãã®ã§ï¼ã¡ãã£ã¨å¾ ã£ã¦ããåè©¦è¡ sleep( 0.2 ) total_wait_sec = total_wait_sec + 0.2 endif wend result = elem fend // å ¥å procedure type( browser, locator, str ) elem = to_elem( browser, locator ) elem.value = str pause( browser ) fend // ã¯ãªã㯠procedure click( browser, locator ) elem = to_elem( browser, locator ) elem.click pause( browser ) fend // ã¯ãªãã¯ãã¦å¾ æ© procedure click_and_wait( browser, locator ) click( browser, locator ) wait( browser ) fend // æè¨ãã¼ã¹ã§ã»ã¬ã¯ãããã¯ã¹ãé¸æ procedure select_by_label( browser, locator, label ) elem = to_elem( browser, locator ) for i = 0 to elem.options.length - 1 ifb elem.options[ i ].innerText = label then elem.options[ i ].selected = True endif next pause( browser ) fend // å¤ãã¼ã¹ã§ã»ã¬ã¯ãããã¯ã¹ãé¸æ procedure select_by_value( browser, locator, val ) elem = to_elem( browser, locator ) for i = 0 to elem.options.length - 1 ifb elem.options[ i ].Value = val then elem.options[ i ].selected = True endif next pause( browser ) fend // indexãã¼ã¹ã§ã»ã¬ã¯ãããã¯ã¹ãé¸æ procedure select_by_index( browser, locator, index ) elem = to_elem( browser, locator ) elem.options[ index ].selected = True pause( browser ) fend // ãã¡ã¤ã«ã¢ãããã¼ã // DOM IDã§ã¯ãªãnameã§è¦ç´ ãæå®ããã®ã§æ³¨æ procedure file_upload( browser, post_name, file_path ) IESetData( browser, file_path, post_name ) pause( browser ) fend // -------------------- JavaScriptã®å¶å¾¡ -------------------- // URLã«ã¸ã£ã³ããï¼Webãã¼ã¸ã«JSã³ã¼ããæ³¨å ¥ãã procedure jump_with_js( browser, url ) IE.jump( browser, url ) IE.create_js_proxy( browser ) fend // Webãã¼ã¸ä¸ã«JSçµç±ç¨ã®ãªãã¸ã§ã¯ããçæãã¦è¿ã procedure create_js_proxy( browser ) doc = browser.document TextBlock js_proxy_code // UWSCããã³ã¼ãæ³¨å ¥ããããã®ãªãã¸ã§ã¯ã document._uwsc_proxy = { global : this, _window : window, eval_code : function( str ){ try{ return eval( str ); }catch( e ){ // ã¨ã©ã¼ã¡ãã»ã¼ã¸ã表示 alert( e.number + " : " + e.description ); return null; } } }; endTextBlock // çæ elem_s = doc.createElement("script") elem_s.text = js_proxy_code; elem_s.type = "text/javascript"; // æ³¨å ¥ doc.getElementsByTagName("head").Item(0).appendChild( elem_s ); fend // æååãJSã³ã¼ãã¨ãã¦ãã©ã¦ã¶å´ã§è©ä¾¡ procedure export_js( browser, str_jscode ) browser.document._uwsc_proxy.eval_code( str_jscode ) fend // æååãJSã³ã¼ãã¨ãã¦è©ä¾¡ããçµæãUWSCå´ã¸èªã¿è¾¼ã¿ function import_js( browser, str_jscode ) // ãã£ããæååããã©ã¦ã¶å´ã«exportãï¼ãã®çµæãUWSCå´ã«import result = browser.document._uwsc_proxy.eval_code( str_jscode ) fend // -------------------- ãã¡ã¤ã«ãã¦ã³ãã¼ãç¨ -------------------- // ãã¤ã¢ãã°ãç¾ããã¾ã§å¾ æ© procedure wait_for_dialog( dialog_title, timeout_sec ) interval_sec = 0.2 total_wait_sec = 0 loop_flag = True while loop_flag // ãã¤ã¢ãã°ã¯ç¾ããã ifb getid( dialog_title, "#32770", -1 ) > -1 then loop_flag = false else sleep( interval_sec ) total_wait_sec = total_wait_sec + interval_sec endif // ã¿ã¤ã ã¢ã¦ãã ifb total_wait_sec > timeout_sec then msgbox( "dialog '" + dialog_title + "' did not appear." ) end_manipulation() endif wend fend // ãã¤ã¢ãã°ã«ãã¼ãéä¿¡ procedure send_dialog( dialog_title, key_code ) // åºç¾ãå¾ ã¤ wait_for_dialog( dialog_title, 10 ) sleep(1) // ãã¼æ¼ä¸ id = getid( dialog_title, "#32770", -1 ) sckey( id, key_code ) fend // ãã¡ã¤ã«ã®ãã¦ã³ãã¼ããã¤ã¢ãã°ãåºãã¨ãã«ï¼ãã¦ã³ãã¼ãï¼ä¿åãå®è¡ procedure save_downloaded_file( browser ) sleep(2) IE.send_dialog( "ãã¡ã¤ã«ã®ãã¦ã³ãã¼ã", vk_s ) IE.send_dialog( "ååãä»ãã¦ä¿å", vk_return ) fend // -------------------- ãã¦ã¹æä½ç¨ -------------------- // ãã©ã¦ã¶ã®body(表示é å)ããwindowã¾ã§ã®ä½ç½é·ãè¨ç® procedure get_client_margins( browser, var xy_margin[] ) // mousemoveæã®æåãå®ç¾© IE.export_js( _ browser, _ "document.onmousemove = function(){ " _ + "document._uwsc_proxy._mouse_x = event.x;" _ + "document._uwsc_proxy._mouse_y = event.y;" _ + "};" _ ) // å¯è¦é åä¸ã ãã®åº§æ¨ãè¦ãã°ããã®ã§ï¼document.scrollTopã足ããªã // mousemoveã¤ãã³ããçºçããã¦ï¼bodyå ã®åº§æ¨ãåå¾ LockHard(True) mouse_screen_x = 500 mouse_screen_y = 500 mmv( mouse_screen_x, mouse_screen_y ) mouse_client_x = IE.import_js( browser, "document._uwsc_proxy._mouse_x" ) mouse_client_y = IE.import_js( browser, "document._uwsc_proxy._mouse_y" ) LockHard(False) // å·®åãåå¾ client_margin_x = mouse_screen_x - mouse_client_x client_margin_y = mouse_screen_y - mouse_client_y // è¿å´ xy_margin["x"] = client_margin_x xy_margin["y"] = client_margin_y fend // DOMè¦ç´ ã®ã¹ã¯ãªã¼ã³ä¸ã§ã®åº§æ¨ãåå¾ procedure get_element_screen_position( browser, locator, var xy_elem_screen[] ) // ä½ç½é·ãåå¾ HashTbl xy_margin IE.get_client_margins( browser, xy_margin ) client_margin_x = xy_margin["x"] client_margin_y = xy_margin["y"] // è¦ç´ ã®ã¹ã¯ãªã¼ã³ä¸ä½ç½®ãè¨ç® elem = IE.to_elem( browser, locator ) elem_client_y = elem.offsetTop - IE.import_js( browser, "document.body.scrollTop" ) elem_client_x = elem.offsetLeft - IE.import_js( browser, "document.body.scrollLeft" ) elem_screen_y = elem_client_y + client_margin_y elem_screen_x = elem_client_x + client_margin_x // è¿å´ xy_elem_screen["x"] = elem_screen_x xy_elem_screen["y"] = elem_screen_y fend // è¦ç´ ã®ä¸ã«ãã¦ã¹ã移å procedure mouse_over_on_elem( browser, locator, var xy_elem_center_screen[] ) elem = IE.to_elem( browser, locator ) // è¦ç´ ã®ã¹ã¯ãªã¼ã³ä¸ã®ä½ç½®ãåå¾ HashTbl xy_elem_screen IE.get_element_screen_position( browser, elem, xy_elem_screen ) elem_screen_x = xy_elem_screen["x"] elem_screen_y = xy_elem_screen["y"] //msgbox( elem_screen_x + " " + elem_screen_y ) // è¦ç´ ã®ä¸å¿ã¸ãã¦ã¹ç§»å elem_center_x = elem_screen_x + ( Val( ChgMoj( elem.offsetWidth, "px", "" ) ) / 2 ) elem_center_y = elem_screen_y + ( Val( ChgMoj( elem.offsetHeight, "px", "" ) ) / 2 ) //msgbox( elem_center_x + " " + elem_center_y ) mmv( elem_center_x, elem_center_y ) sleep(1) // éå§ç¹ãè¿ã xy_elem_center_screen["x"] = elem_center_x xy_elem_center_screen["y"] = elem_center_y fend // æå®è¦ç´ ã®ãã©ãã°ãéå§ procedure start_drag( browser, locator, var xy_start_screen[] ) elem = IE.to_elem( browser, locator ) // è¦ç´ ã®ä¸å¿ã¸ãã¦ã¹ç§»å HashTbl xy_elem_center_screen IE.mouse_over_on_elem( browser, elem, xy_elem_center_screen ) drag_start_x = xy_elem_center_screen["x"] drag_start_y = xy_elem_center_screen["y"] // è¦ç´ ãã¯ãªã㯠btn( LEFT, DOWN, drag_start_x, drag_start_y ) sleep(1) // éå§ç¹ãè¿ã xy_start_screen["x"] = drag_start_x xy_start_screen["y"] = drag_start_y fend // æå®è¦ç´ ããã©ãã°ãããã // è¦ç´ ã¨ï¼ç§»åè·é¢ã¨ï¼æè¦æéãæå® procedure drag_drop( browser, locator, move_by_x, move_by_y, total_sec ) elem = IE.to_elem( browser, locator ) // ãã©ãã°éå§ HashTbl xy_start_screen IE.start_drag( browser, elem, xy_start_screen ) start_screen_x = xy_start_screen["x"] start_screen_y = xy_start_screen["y"] // 移å LockHard(True) interval_sec = 0.2 // ã«ã¼ãä¸åã«ãããç§æ° move_step_num = total_sec / interval_sec // 移åã«è¦ããã¹ãããæ° step_x = move_by_x / move_step_num // 1ã¹ãããã®ç§»åè·é¢ step_y = move_by_y / move_step_num moved_x = 0 // ç´¯ç©ç§»åè·é¢ moved_y = 0 i = 0 while i < move_step_num moved_x = step_x * ( i + 1 ) moved_y = step_y * ( i + 1 ) mmv( start_screen_x + moved_x, start_screen_y + moved_y ) sleep( interval_sec ) i = i + 1 wend // å·¦ãã¿ã³ãä¸ãã btn( LEFT, UP, start_screen_x + move_by_x, start_screen_y + move_by_y ) LockHard(False) sleep(1) fend // -------------------- ãã¹ãå®è¡ç¨ -------------------- // è¦ç´ ã®å¤ãæ¤è¨¼ procedure assert_value( browser, locator, val_expected ) elem = to_elem( browser, locator ) val_real = elem.value assert_str( val_expected, val_real ) fend // è¦ç´ å ã®æååãæ¤è¨¼ procedure assert_text( browser, locator, val_expected ) elem = to_elem( browser, locator ) val_real = elem.innerText assert_str( val_expected, val_real ) fend // æååå士ãæ¯è¼ procedure assert_str( val_expected, val_real ) log_str = "æå¾ å¤ : '" + val_expected + "', å®éã®å¤ : '" + val_real + "'" // ä¸è´ããã ifb val_expected = val_real then // OK try_assert_log( "OK", log_str ) else try_assert_log( "NG", log_str ) msgbox( "NG : " + log_str ) quit_by_fail_assert() endif fend // assert失ææã«å¼·å¶çµäº procedure quit_by_fail_assert() // ãã°ãéãã save_and_close_logfile() // ã¹ã¯ãªãããå¼·å¶çµäº end_manipulation() fend // è¦ç´ ãåå¨ãããã¨ãæ¤è¨¼ procedure assert_element_present( browser, dom_id ) ifb is_element_present( browser, dom_id ) then try_assert_log( "OK", "DOMè¦ç´ '" + dom_id + "' ã¯åå¨" ) else ng_str = "DOMè¦ç´ '" + dom_id + "' ã¯éåå¨" try_assert_log( "NG", ng_str ) msgbox( "NG : " + ng_str ) quit_by_fail_assert() endif fend // è¦ç´ ãåå¨ããªããã¨ãæ¤è¨¼ procedure assert_element_not_present( browser, dom_id ) ifb is_element_present( browser, dom_id ) then ng_str = "DOMè¦ç´ '" + dom_id + "' ã¯åå¨" try_assert_log( "NG", ng_str ) msgbox( "NG : " + ng_str ) quit_by_fail_assert() else try_assert_log( "OK", "DOMè¦ç´ '" + dom_id + "' ã¯éåå¨" ) endif fend // JavaScriptã®å®è¡çµæãæ¤è¨¼ procedure assert_jscode( browser, str_jscode, str_expected ) val_expected = import_js( browser, str_expected ) val_real = import_js( browser, str_jscode ) ifb val_expected = val_real then // OK try_assert_log( "OK", "ä¸è´" ) else try_assert_log( "NG", "ä¸ä¸è´" ) msgbox( "NG : " + "ä¸ä¸è´" ) quit_by_fail_assert() endif fend // -------------------- ãã®ã³ã°ç¨ -------------------- // ãã°ãåããã©ããã®ãã©ã° dim _use_log_flag = False // ãã°ç¨ã®Excelãã¡ã¤ã«å dim _log_xls_path // ãã°ç¨ã®Excelãã¡ã¤ã«ãªãã¸ã§ã¯ã dim _log_xls_obj = Nothing // ç¾å¨ã®ãã°åºåå ã·ã¼ã dim _log_sheet_name // ç¾å¨ã®ãã°åºåå è¡çªå· dim _log_col_num // ç¾å¨ã®ãã°åºåå åçªå· dim _log_row_num // ãã°ãåããã©ããè¨å®ãã procedure use_log( flag ) _use_log_flag = flag fend // assertæã®ãã°åºå procedure try_assert_log( summary_str, log_str ) ifb _use_log_flag = True then record_log( summary_str, log_str ) endif fend // ãã°åºå procedure record_log( summary_str, log_str ) //msgbox( summary_str ) target_sheet = _log_xls_obj.Sheets( _log_sheet_name ) // 1åç®ã«ã¯ãµããªï¼OK/NGï¼ target_sheet.Cells( _log_col_num, _log_row_num ).Value = summary_str // 2åç®ã«ã¯è©³ç´° target_sheet.Cells( _log_col_num, _log_row_num + 1 ).Value = log_str // 3åç®ã«ã¯æ¥ä» target_sheet.Cells( _log_col_num, _log_row_num + 2 ).Value = "'" + current_time_for_log() fend // ãã°åºåç¨ã®Excelãè¨å®ãã¦éã procedure open_xls_as_logfile( xls_path ) // éã _log_xls_obj = open_logfile_with_new_excel( xls_path ) _log_xls_path = xls_path ifb _log_xls_obj.ActiveWorkBook.ReadOnly = -1 then msgbox( "ã¨ã©ã¼ï¼è¨é²ç¨ã®Excelãã¡ã¤ã«ãäºéã«éããã¦ãã¾ããéãã¦ããåå®è¡ãã¦ãã ããã" ) close_logfile() exitexit endif // æå°å xlMinimized = -4140 _log_xls_obj.WindowState = xlMinimized fend // ãã°ãã¡ã¤ã«ãéã function open_logfile_with_new_excel( xls_path ) excel = createOLEobj("Excel.Application") excel.Visible = True excel.WorkBooks.Open( xls_path ) result = excel fend // ãã°åºåç¨ã®Excelãä¿å procedure save_xls_as_logfile() ifb !( _log_xls_obj = Nothing ) then _log_xls_obj.DisplayAlerts = False book = _log_xls_obj.Workbooks( _log_xls_obj.Workbooks.Count ) // ä¸æ¸ãä¿å book.SaveAs( _log_xls_path ) _log_xls_obj.DisplayAlerts = True endif fend // ãã°åºåç¨ã®Excelãéãã procedure close_logfile() ifb !( _log_xls_obj = Nothing ) then book = _log_xls_obj.Workbooks( _log_xls_obj.Workbooks.Count ) // éãã book.Close _log_xls_obj.Quit() endif fend // ãã°ãä¿åãã¦éãã procedure save_and_close_logfile() ifb !( _log_xls_obj = Nothing ) then save_xls_as_logfile() close_logfile() endif fend // ãã°åºåå ã®ã·ã¼ãåã¨ã»ã«ä½ç½®ãã»ãã procedure set_pgcount( sheet_name, xls_col_num, xls_row_num ) // ä¿æ _log_sheet_name = sheet_name _log_col_num = xls_col_num _log_row_num = xls_row_num fend // ãã°ã®çµæãé²è¦§ãããã©ããç¢ºèª procedure confirm_show_logging_result() ifb MsgBox("çµäºãã¾ããããã°ãé²è¦§ãã¾ããï¼", BTN_YES or BTN_NO) = BTN_YES then excel = open_logfile_with_new_excel( _log_xls_path ) excel.ActiveWorkbook.Saved = True endif fend // -------------------- å ±éã¦ã¼ãã£ãªã㣠-------------------- // ç¾å¨æå»ããã°ç¨ã«æååã§è¿ã function current_time_for_log() GetTime() result = G_TIME_YY4 _ + "/" _ + dig2( G_TIME_MM ) _ + "/" _ + dig2( G_TIME_DD ) _ + " " _ + dig2( G_TIME_HH ) _ + ":" _ + dig2( G_TIME_NN ) _ + ":" _ + dig2( G_TIME_SS ) _ + ":" _ + dig3( G_TIME_ZZ ) fend // æ°å¤ã2æ¡ã«0åã function dig2( num ) ifb num < 10 then str = "0" + num else str = "" + num endif result = str fend // æ°å¤ã3æ¡ã«0åã function dig3( num ) ifb num < 10 then str = "00" + num elseif num < 100 then str = "0" + num else str = "" + num endif result = str fend endclass
700è¡ãããã
æ¬å½ã¯é¨åã¢ã¸ã¥ã¼ã«ãã¨ã«åå²ããããï¼UWSCã®ä»æ§ä¸ç¡çãªã®ã§ï¼ã¤ã®ãã¡ã¤ã«ã«ããã
ããç¨åº¦ãªãã¡ã¯ã¿ãªã³ã°ãã¦ãããã¤ããã
å®è£ ã®ããï¼
- ã¯ã©ã¹å¤æ°ã¯å é ã«_ãã¤ãã¦ãããã§ãªãã¨ï¼ä½ã®å¤æ°ãªã®ãããããªããªã£ã¦ãã¾ããï¼this.ã¨ãç¡ãã«å¼ã³åºããã®ã§ï¼
- Excelãäºéã«éããªãããã«ããããã®ãã§ãã¯ãé¢åã ã£ãã
è£è¶³
assertã®ãã³ã«set_pgcount()ãæ¸ãå¿ è¦ãããã
èªåçã«æ¸ã対象ã®ã»ã«ããããã¦ããã°ãããããªããï¼ã¨è¨ããããã ãï¼ããããªãã®ã«ã¯è¨³ãããã
ãã®çç±ã¯ï¼ãããæããã«ãããã
â追è¨ï¼ä¸è¨ã§æããã«ãã¾ããã
IE AutoTester ã§ï¼UIã®å帰ãã¹ããå®å ¨èªåå
http://d.hatena.ne.jp/language_and_engineering/20090922/p1
é¢é£ããè¨äºï¼
UWSCã®ãã¯ãã§ï¼IEãèµ·åãã¦èªåæä½ãããµã³ãã«ã³ã¼ã - 主ã«è¨èªã¨ã·ã¹ãã éçºã«é¢ãã¦
http://d.hatena.ne.jp/language_and_engineering/20140204/controlIeBrowserbyUWSC
JScript / VBScript (WSH)ã§ï¼IEãèªåæä½ããã - 主ã«è¨èªã¨ã·ã¹ãã éçºã«é¢ãã¦
http://d.hatena.ne.jp/language_and_engineering/20090713/p1
IE AutoTester ã§ï¼UIã®å帰ãã¹ããå®å ¨èªåå - 主ã«è¨èªã¨ã·ã¹ãã éçºã«é¢ãã¦
http://d.hatena.ne.jp/language_and_engineering/20090922/p1
ã
ã