我使用web_browser.document.getElementById()登录屏幕它工作正常,但登录后打开一个新窗口web_browser.document.getElementById似乎不起作用请帮助。请找到以下代码:
My_User_Name := "My_User_Name"
My_Pass_Word := "My_User_Name"
My_Batch := "C1-ADMOV"
web_browser := ComObjCreate("InternetExplorer.Application")
web_browser.Visible := true
web_browser.Navigate("http://example.com")
while web_browser.busy ; a while loop is a way to keep the script testing an IF like expression
sleep 100 ; IF web_browser.busy is true then sleep 100 milliseconds
username_input := web_browser.document.getElementById("userId")
username_input.value := My_User_Name
password_input := web_browser.document.getElementById("password")
password_input.value := My_Pass_Word
web_browser.document.getElementById("loginButton").click()
while web_browser.busy ; a while loop is a way to keep the script testing an IF like expression
sleep 100 ; IF web_browser.busy is true then sleep 100 milliseconds
web_browser.Navigate2("http://example.com/batches")
while web_browser.busy ; a while loop is a way to keep the script testing an IF like expression
sleep 1000 ; IF web_browser.busy is true then sleep 1000 milliseconds
BATCH_CD_input := web_browser.document.getElementById("BATCH_CD")
BATCH_JOB_ID_input := web_browser.document.getElementById("BATCH_JOB_ID")
BATCH_CD_input.value := My_Batch
BATCH_JOB_ID_input.value:= "96090087688130"
web_browser.document.getElementById("lIM_Altr_bjSrch").click()
web_browser.document.getElementById("IM_Main_batjobSrch").click()
web_browser.document.getElementById("ACTION_Q_SW").click()
Return
答案 0 :(得分:0)
要访问您未使用ComObjCreate
创建的现有Internet Explorer窗口,请使用以下内容:
web_browser_from_active_window := IeGet()
web_browser_2 := IeGet("Login site bla bla")
IeGet(winTitle:="A") {
WinGetTitle, title, % winTitle
For window in ComObjCreate("Shell.Application").windows
If (InStr(window.fullName, "iexplore.exe") && window.document.title . " - Internet Explorer" = title)
Return window
Return {}
}
答案 1 :(得分:0)
I managed to get elements I want on webpage. What I did instead of navigating to login page and enter credentials, I just navigate to the webpage I want to get elements in. I only have web_browser.Navigate2("http://example.com/batches"). This sorted my issue
My_User_Name := "My_User_Name"
My_Pass_Word := "My_User_Name"
My_Batch := "C1-ADMOV"
web_browser := ComObjCreate("InternetExplorer.Application")
web_browser.Visible := true
web_browser.Navigate2("http://example.com/batches")
while web_browser.busy ; a while loop is a way to keep the script testing an IF like expression
sleep 100 ; IF web_browser.busy is true then sleep 100 milliseconds
username_input := web_browser.document.getElementById("userId")
username_input.value := My_User_Name
password_input := web_browser.document.getElementById("password")
password_input.value := My_Pass_Word
web_browser.document.getElementById("loginButton").click()
while web_browser.busy ; a while loop is a way to keep the script testing an IF like expression
sleep 100 ; IF web_browser.busy is true then sleep 100 milliseconds
while web_browser.busy ; a while loop is a way to keep the script testing an IF like expression
sleep 1000 ; IF web_browser.busy is true then sleep 1000 milliseconds
BATCH_CD_input := web_browser.document.getElementById("BATCH_CD")
BATCH_JOB_ID_input := web_browser.document.getElementById("BATCH_JOB_ID")
BATCH_CD_input.value := My_Batch
BATCH_JOB_ID_input.value:= "96090087688130"
web_browser.document.getElementById("lIM_Altr_bjSrch").click()
web_browser.document.getElementById("IM_Main_batjobSrch").click()
web_browser.document.getElementById("ACTION_Q_SW").click()
Return