vbscript에서 브라우저 (IE)를 GUI로 사용하는 것이 일반적입니다. 아래 예제를 참조하면 이름을 묻고 스크립트에 반환합니다. Ruby에는 Tcl과 Shoes와 같은 몇 가지 GUI가 있지만 브라우저에서이를 수행하는 방법을 궁금해합니다. 가장 간단한 루비 솔루션은 무엇입니까? 그래서 exta 보석이나 꾸러미가 없습니다. 이미 실행중인 서버가 없습니다 .. 보석이 필요한 경우, 문제없이 Windows에서 작동하는 것이 좋습니다. 여기Ruby에서 브라우저를 GUI로 사용
Set web = CreateObject("InternetExplorer.Application")
If web Is Nothing Then
msgbox("Error while loading Internet Explorer")
Wscript.Quit
Else
with web
.Width = 300
.Height = 175
.Offline = True
.AddressBar = False
.MenuBar = False
.StatusBar = False
.Silent = True
.ToolBar = False
.Navigate "about:blank"
.Visible = True
end with
End If
'Wait for the browser to navigate to nowhere
Do While web.Busy
Wscript.Sleep 100
Loop
'Wait for a good reference to the browser document
Set doc = Nothing
Do Until Not doc Is Nothing
Wscript.Sleep 100
Set doc = web.Document
Loop
'Write the HTML form
doc.Write "Give me a name<br><form><input type=text name=name ><input type=button name=submit id=submit value='OK' onclick='javascript:submit.value=""Done""'></form>"
Set oDoc = web.Document
Do Until oDoc.Forms(0).elements("submit").Value <> "OK"
Wscript.Sleep 100
If web Is Nothing or Err.Number <> 0 Then
msgbox "Window closed"
Wscript.Quit
End If
Loop
name = oDoc.Forms(0).elements("name").value
oDoc.close
set oDoc = nothing
web.quit
set web = nothing
Wscript.echo "Hello " & name
GUI는 GRAPHICAL 사용자 인터페이스입니다. 간단한 콘솔 텍스트 인터페이스이지만 셀렌 솔루션을 사용해 보겠습니다. 덕분에 – peter
스크립트가 실패하고 셀렌을 사용했지만 현재는 실패합니다. 버전 파이어 폭스 14.0.1의 문제점 : C : /Ruby193/lib/ruby/gems/1.9.1/gems/selenium-webdriver-2.20.0/lib/selenium/webdriver/firefox/launcher.rb : 77 :'connect_until_stable ' : 안정적인 firefox 연결을 얻을 수 없습니다. (127.0.0.1:7055) (Selenium :: WebDriver :: Error :: WebDriverError) 하지만 어떻게 값을 전달하고 얻을 것입니까? – peter
당신은 가장 단순하고 보석이 없다고 말했습니다;) 실패한 스크립트에 관해서는이 [link]를보십시오 (http://stackoverflow.com/questions/7263564/unable-to-obtain-stable-firefox-connection-in -60-seconds-127-0-0-17055). 그러나 그것은 Firefox의 버전 일 수 있습니다, 위의 작동하지 않는 경우 낮은 버전으로 전환하십시오. 나는 당신이 자동화에 대해 말하고 있다면 엑셀 파일을 사용하고 거기서 데이터를 얻거나 쓸 수 있다는 것을 '어떻게 전달하고 값을 얻는가'라는 것이 무엇을 의미하는지 모르겠다 .. –