å
æ¥ãâããã使ã£ã¦ãã©ã¦ã¶ãããµã¼ãã«ãã¡ã¤ã«ãã¢ãããã¼ãããã¨ããç»é¢ãä½ã£ã¦ãã¾ããã
ä½ãã¾ã§ã¯ããã£ããã§ãããããã SeleniumRC ã§ãã¹ããããã¨æã£ããã»ã»ã»ãã¡ã¤ã«æ¬ã®æä½ã¯ã§ããªãããã§ã(Selenium Core FAQ - Selenium - OpenQA Wiki)
Firefoxãªãã§ããã¨ã®ãã¨ã§ããããã¹ãããããã©ã¦ã¶ã¯IE6/7/8ã
ãããããªãã®ã§ããããªåæã§çªç ´ãã¾ããã
/** * ãã¡ã¤ã«å ¥åæ¬(input[@type=file])ã«ãã¢ãããã¼ããã¡ã¤ã«ãè¨å®ãã¾ãã * ãã®ã¡ã½ããã¯ãIE6/7ã§ã®ã¿å®è¡ã§ãã¾ãã * å®è¡ä¸ã¯ãJavaã§ãã©ã¦ã¶ãç´æ¥æä½ãããããPCã«è§¦ãã¦ã¯ããã¾ããã * ã¢ã¯ãã£ãã¦ã£ã³ãã¦ãå¥ã®ã¦ã£ã³ãã¦ã«ãªã£ã¦ããå ´åããã®å¦çã¯å¤±æãã¾ãã * * @param locator ãã¡ã¤ã«å ¥åæ¬ * @param file ã¢ãããã¼ããããã¡ã¤ã« */ protected void attachFileForIE(String locator, File file) { String path = file.getAbsolutePath(); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); StringSelection selection = new StringSelection(path); clipboard .setContents(selection, null); selenium.focus(locator); selenium.keyDownNative(String.valueOf(KeyEvent.VK_CONTROL)); selenium.keyPressNative(String.valueOf(KeyEvent.VK_V)); selenium.keyUpNative(String.valueOf(KeyEvent.VK_CONTROL)); }
ãã¡ã¤ã«ã®ãã¹ãã¯ãªãããã¼ãã«ã³ãã¼ãã¦ããã©ã¦ã¶ã® input type=file ã«è²¼ãä»ããã¨ããåæã
å
ã«ãªã£ãã¢ã¤ãã£ã¢ï¼Selenium RC > how to upload file using attachFile() - Stack Overflowï¼ã§ã¯ãä¸æåãã¤å
¥åãã¦ãã¾ããããã£ã¡ã®ã»ããæã£åãæ©ãã§ãã
IE6/7ã®ã¿ããã®æ¬ã«ç´æ¥å
¥åãå¯è½ãªã®ã§ããã®æ¹æ³ãã¨ãã¾ãã
ãã ãIE8ããã¯ã»ãã¥ãªãã£ä¸ã®çç±ã§ããã®æ¹æ³ãã§ããªããªã£ã¦ãã¾ãã
ãã¡ã¤ã«ã®ã¢ãããã¼ãå¶å¾¡
æ´å²çã«è¦ã¦ãHTML ã® ãã¡ã¤ã« ã¢ãããã¼ã ã³ã³ããã¼ã« (input type=file) ã¯ããªãã®æ°ã®å ¬éãããèå¼±æ§ã®æ¸©åºã§ããç¶ãã¾ããããã®åé¡ã解決ããããããã®ã³ã³ããã¼ã«ã®åä½ã«ã¤ãã¦äºã¤ã®å¤æ´ãå ãã¾ãããã¦ã¼ã¶ã¼ã®å ¥åãããã¼ã«ã«ã®ãã¡ã¤ã« ãã¹ããã¼ã¹ããã¼ã¯ã®ç£è¦ã«ãã£ã¦çãæ»æãé²ãããããã¡ã¤ã« ãã¹ã®ç·¨éããã¯ã¹ãèªã¿åãå°ç¨ã¨ãã¾ããããã¡ã¤ã«ãã¢ãããã¼ãããå ´åããã¡ã¤ã«ã®åç §ãã¤ã¢ãã°ãå©ç¨ãã¦ããã¡ã¤ã«ãæå®ããå¿ è¦ãããã¾ãã
http://msdn.microsoft.com/ja-jp/ie/dd218483.aspx
ï¼IE8からはinput type=fileのテキストボックスに直接入力できなくなった - 大人になったら肺呼吸ããç¥ãã¾ããï¼
ãã©ã¦ã¶ã®èªåãã¹ãã¯ããªã«ãã¨ããã©ãããã§ããã»ã»ã»ã