{"id":171,"date":"2016-09-29T22:42:25","date_gmt":"2016-09-29T13:42:25","guid":{"rendered":"http:\/\/okamurax.com\/?p=171"},"modified":"2016-12-23T10:09:29","modified_gmt":"2016-12-23T01:09:29","slug":"vba-selenium%e3%81%ae%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/appbay.org\/?p=171","title":{"rendered":"VBA Selenium\u306e\u64cd\u4f5c"},"content":{"rendered":"<p>SeleniumWrapper Type Library\u306e\u53c2\u7167\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3059\u308b\u3002<\/p>\n<pre class=\"lang:vb decode:true  \">Sub test()\r\n\r\n\tDim driver As New SeleniumWrapper.WebDriver\r\n\tdriver.Start \"ie\", \"https:\/\/www.google.co.jp\/\"\r\n\r\n\t'driver.setImplicitWait (500)\r\n\r\n\tdriver.get (\"\/\")\r\n\tdriver.findElementById(\"lst-ib\").SendKeys \"Selenium\"\r\n\tdriver.findElementByName(\"btnG\").Click\r\n\r\n\tdriver.findElementByLinkText(\"Selenium WebDriver\u3067Web\u30a2\u30d7\u30ea\u306e\u30c6\u30b9\u30c8\u304c\u5909\u308f\u308b - IT\", 5000).Click\r\n\r\n\t'driver.stop\r\n\tMsgBox \"\"\r\n  \r\nEnd Sub\r\n\r\nSub test()\r\n\r\n\tDim driver As New SeleniumWrapper.WebDriver\r\n\r\n\tCall driver.Start(\"ie\", \"https:\/\/www.google.co.jp\/\")\r\n\tCall driver.get(\"\/cgi-bin\/idxsearch.cgi\")\r\n\r\n\tCall driver.findElementByName(\"Y_TYPE\").AsSelect.selectByIndex(1) '0\u306f\u3058\u307e\u308a\r\n\t'Call driver.findElementByName(\"Y_TYPE\").AsSelect.selectBytext(\"\u3044\u305a\u308c\u304b\u306e\u7528\u8a9e\u3092\u542b\u3080\")\r\n\r\nEnd Sub\r\n\r\nSub test()\r\n\r\n\tDim driver As New SeleniumWrapper.WebDriver\r\n\r\n\tCall driver.Start(\"ie\", \"https:\/\/www.google.co.jp\/\")\r\n\tCall driver.get(\"\/cgi-bin\/idxsearch.cgi\")\r\n\r\n\tCall driver.findElementsByName(\"H_YOMI_GUN\").Item(3).Click\r\n    \r\nEnd Sub\r\n\r\nSub test()\r\n\r\n\tDim driver As New SeleniumWrapper.WebDriver\r\n\tCall driver.Start(\"ie\", \"https:\/\/www.google.co.jp\/\")\r\n\tCall driver.get(\"search\/servlet\/Procedure?CLASSNAME=GTAEGOVMSTSEARCH\")\r\n\r\n\tDim collection As WebElementCollection\r\n\r\n\tSet collection = driver.findElementsByName(\"HushoSeqNo\")\r\n\r\n\tcollection.Item(0).Click\r\n\tcollection.Item(1).Click\r\n\tcollection.Item(2).Click\r\n\tcollection.Item(3).Click\r\n\r\nEnd Sub\r\n\r\nSub test()\r\n\r\n\tDim driver As New SeleniumWrapper.WebDriver\r\n\tCall driver.Start(\"ie\", \"https:\/\/www.google.co.jp\/\")\r\n\tCall driver.get(\"\/\")\r\n\r\n\tdriver.findElementByCssSelector(\"#one-content &gt; a:nth-child(1) &gt; img:nth-child(1)\").Click\r\n\r\nEnd Sub\r\n\r\nSub test()\r\n\r\n\tDim driver As New SeleniumWrapper.WebDriver\r\n\tCall driver.Start(\"ie\", \"http:\/\/www.google.com\/\")\r\n\tCall driver.get(\"\/\")\r\n\r\n\tMsgBox driver.URL\r\n\r\nEnd Sub\r\n\r\nSub test()\r\n\r\n\tDim driver As New SeleniumWrapper.WebDriver\r\n\tdriver.Start \"ie\", \"http:\/\/www.google.com\/\"\r\n\tdriver.get \"\/\"\r\n\tdriver.findElementByName(\"q\").SendKeys (\"\u3055\u3070\u306e\u5473\u564c\u716e\")\r\n\tdriver.findElementByName(\"btnG\").Click\r\n\r\n\tCall driver.waitForTextPresent(\"\u306b\u95a2\u9023\u3059\u308b\u691c\u7d22\u30ad\u30fc\u30ef\u30fc\u30c9\")\r\n\t'Call driver.toClipBoard(driver.findElementByTagName(\"body\").Text)\r\n\r\nEnd Sub\r\n\r\nSub test()\r\n\r\n\tDim driver As New SeleniumWrapper.WebDriver\r\n\tCall driver.Start(\"ie\", \"http:\/\/www.google.com\/\")\r\n\tCall driver.get(\"\/\")\r\n\r\n\tdriver.windowMaximize\r\n\r\nEnd Sub\r\n\r\nSub test()\r\n\r\n\tDim driver As New SeleniumWrapper.WebDriver\r\n\tdriver.Start \"ie\", \"http:\/\/www.google.com\/\"\r\n\tdriver.get \"\/\"\r\n\tdriver.findElementByName(\"q\").SendKeys (\"xxx\")\r\n\tdriver.findElementByName(\"btnG\").Click\r\n\r\n\tdriver.waitForTextPresent (\"\u306b\u95a2\u9023\u3059\u308b\u691c\u7d22\u30ad\u30fc\u30ef\u30fc\u30c9\")\r\n\tdriver.getScreenshot().Copy\r\n\tdriver.getScreenshot().SaveAs (\"SABA_NO_MISO_NI.bmp\")\r\n\r\nEnd Sub\r\n\r\nSub test()\r\n\r\n\tDim driver As New SeleniumWrapper.WebDriver\r\n\tdriver.Start \"ie\", \"http:\/\/homepage3.nifty.com\/abe-hiroshi\/\"\r\n\tdriver.setImplicitWait 1000000\r\n\tdriver.get \"\/\"\r\n\r\n\tDim frameUrl: frameUrl = driver.findElementsByTagName(\"frame\").Item(1).getAttribute(\"src\")\r\n\tdriver.get frameUrl\r\n\r\nEnd Sub\r\n\r\nSub test()\r\n\r\n\tDim driver As New SeleniumWrapper.WebDriver\r\n\t'driver.startRemotely \"ie\", \"http:\/\/192.168.0.26:4444\/wd\/hub\" \"http:\/\/news.yahoo.com\"\r\n\t'\u5225\u9014\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u5fc5\u8981\r\n\r\nEnd Sub\r\n\r\nSub test()\r\n\r\n\tDim driver As New WebDriver\r\n\tCall driver.Start(\"ie\", \"http:\/\/www.red.oit-net.jp\/\")\r\n\tCall driver.get(\"\/tatsuya\/java\/winopen.htm\")\r\n\r\n\tDim beforeHwd As String\r\n\t'\u65e2\u5b58\u306e\u30cf\u30f3\u30c9\u30eb\u3092\u4fdd\u5b58\r\n\tbeforeHwd = driver.WindowHandle 'Returns the handle of the current window.\r\n\r\n\tdriver.findElementByCssSelector(\"table.waku:nth-child(13) &gt; tbody:nth-child(1) &gt; tr:nth-child(1) &gt; td:nth-child(1) &gt; form:nth-child(3) &gt; input:nth-child(1)\").Click\r\n\r\n\t'\u65b0\u3057\u3044\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u958b\u304f\r\n\r\n\t'\u65e2\u5b58\u306e\u30a6\u30a3\u30f3\u30c9\u30a6\u3068\u306f\u9055\u3046\u30a6\u30a3\u30f3\u30c9\u30a6\u3092\u63a2\u3059\r\n\tDim Hwds\r\n\tHwds = driver.WindowHandles ' Returns the handles of all windows within the current session.\r\n\tDim window: For Each window In Hwds\r\n\tIf window &lt;&gt; beforeHwd Then\r\n\t    driver.switchToWindow window '\u3053\u3053\u3067\u65b0\u3057\u3044\u30a6\u30a3\u30f3\u30c9\u30a6\u306b\u5207\u308a\u66ff\u3048\u308b\r\n\t    driver.get \"\/\" '\u65b0\u3057\u3044\u30a6\u30a3\u30f3\u30c9\u30a6\u306b\u5bfe\u3059\u308b\u64cd\u4f5c\r\n\t    driver.Close '\u65b0\u3057\u3044\u30a6\u30a3\u30f3\u30c9\u30a6\u306b\u5bfe\u3059\u308b\u64cd\u4f5c\r\n\tEnd If\r\n\tNext\r\n\r\n\t'\u3082\u3068\u306e\u30a6\u30a3\u30c9\u30a6\u306b\u623b\u3057\u3066\u3044\u308b\u3002\r\n\tSet driver = driver.switchToWindow(beforeHwd) 'Switches focus to the specified window.\r\n\tdriver.get \"\/tatsuya\"\r\n    \r\nEnd Sub\r\n\r\nSub test()\r\n\r\n\tDim selenium As New SeleniumWrapper.WebDriver\r\n\tselenium.Start \"ie\", \"http:\/\/www.google.com\/\"\r\n\tselenium.Open \"\/\"\r\n\tselenium.Type \"name=q\", \"seleniumVBA\"\r\n\tselenium.Click \"name=btnG\"\r\n\tselenium.Wait 1000\r\n\tselenium.getScreenshot().Copy\r\n\tselenium.stop\r\n\tSheets(1).Range(\"A10\").PasteSpecial\r\n   \r\nEnd Sub<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>SeleniumWrapper Type Library\u306e\u53c2\u7167\u8a2d\u5b9a\u3092\u8ffd\u52a0\u3059\u308b\u3002 Sub test() Dim driver As New SeleniumWrapper.WebDriver driver.Start &#8220;i &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/appbay.org\/?p=171\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;VBA Selenium\u306e\u64cd\u4f5c&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[5],"class_list":["post-171","post","type-post","status-publish","format-standard","hentry","category-1","tag-vba"],"_links":{"self":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/171","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=171"}],"version-history":[{"count":1,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/171\/revisions"}],"predecessor-version":[{"id":172,"href":"https:\/\/appbay.org\/index.php?rest_route=\/wp\/v2\/posts\/171\/revisions\/172"}],"wp:attachment":[{"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/appbay.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}