Open GoogleCodeExporter opened 9 years ago
>whats is the reason it's not clicking?
Don't know, but it could be one of the reasons that makes everyone leaving IE
for Chrome or Firefox...
>is there any error in my code?
What code?
>what function do i have to add to click on that link?
webdriver.open "javascript:document.getElementById('overridelink').click()"
Original comment by florentbr
on 10 Oct 2014 at 1:46
You could also try to add the domain to the "Trusted Sites" for i.e. in
"Internet Options".
Original comment by florentbr
on 10 Oct 2014 at 1:51
i did both the things but still its not working.
i want my code to work in IE and Chrome,but its not working in both.
have a look at my code.
suggest me if any solution is there.
Private Sub CommandButton1_Click()
Dim driver As New SeleniumWrapper.WebDriver
Dim shell: Set shell = CreateObject("WScript.Shell")
Dim keys As New SeleniumWrapper.keys
Dim Tdate As String
Dim enddate As String
Dim i As Integer
Dim By As New By, Assert As New Assert, Verify As New Verify, Waiter As New Waiter
rw_cntx = Worksheets("Sheet2").Cells(Worksheets("Sheet2").Rows.Count, 1).End(xlUp).Row
rw_cnt = rw_cntx - 1
MsgBox rw_cnt
Worksheets("Sheet2").Activate
ThisWorkbook.Worksheets("Sheet2").Cells.Copy _
Destination:=Sheet3.Cells
driver.Start "ie", "https://......url......"
driver.Open "https://....url....."
driver.setImplicitWait 5000
driver.findElementById("overridelink").Click
driver.setImplicitWait 5000
driver.maximizeWindow
UserName = Worksheets("Sheet1").Cells(2, 2).Value
Password = Worksheets("Sheet1").Cells(3, 2).Value
driver.findElementById("Username").Click
driver.findElementById("Username").Clear
driver.findElementById("Username").SendKeys UserName
'
driver.findElementById("Password").Clear
driver.findElementById("Password").SendKeys Password
driver.findElementByCssSelector("a.loginBtn").Click
driver.setImplicitWait 5000
Worksheets("Sheet2").Activate
driver.setImplicitWait 1000
driver.setImplicitWait 5000
While rw_cnt > 0
driver.findElementByClassName("imgSize16").Click
driver.setImplicitWait 5000
'driver.findElementByCssSelector("img.imgSize16").Click
driver.findElementById("accountNumber").Clear
'Sheets("Sheet2").Activate
'Application.CutCopyMode = False
'Application.Sheets("Sheet2").Range("A1:A2").Copy
'driver.findElementById("accountNumber").SendKeys keys.Control & "v"
driver.Wait 1000
Worksheets("Sheet2").Activate
Accounts1 = Worksheets("Sheet2").Cells(2, 1).Value
Accounts2 = Worksheets("Sheet2").Cells(3, 1).Value
Accounts3 = Worksheets("Sheet2").Cells(4, 1).Value
Accounts4 = Worksheets("Sheet2").Cells(5, 1).Value
Accounts5 = Worksheets("Sheet2").Cells(6, 1).Value
driver.findElementById("accountNumber").SendKeys Accounts1
driver.setImplicitWait 50
driver.findElementById("accountNumber").SendKeys keys.Enter
driver.setImplicitWait 50
driver.findElementById("accountNumber").SendKeys Accounts2
driver.setImplicitWait 50
driver.findElementById("accountNumber").SendKeys keys.Enter
driver.setImplicitWait 50
driver.findElementById("accountNumber").SendKeys Accounts3
driver.setImplicitWait 50
driver.findElementById("accountNumber").SendKeys keys.Enter
driver.setImplicitWait 50
driver.findElementById("accountNumber").SendKeys Accounts4
driver.setImplicitWait 50
driver.findElementById("accountNumber").SendKeys keys.Enter
driver.setImplicitWait 50
driver.findElementById("accountNumber").SendKeys Accounts5
driver.setImplicitWait 50
'driver.findElementById("accountNumber").SendKeys "376730332161006"
'driver.findElementById("accountNumber").
'driver.findElementById("environment").Click
driver.findElementByXPath("//input[@id='environment']").Click
' driver.findElementByXPath(".//*[@id='environment']").Click
'driver.setImplicitWait 5000
driver.findElementByXPath("(//input[@id='environment'])[2]").Click
driver.findElementByXPath("(//input[@id='environment'])[3]").Click
driver.setImplicitWait 50
driver.findElementByXPath("(//input[@id='environment'])[4]").Click
driver.findElementByXPath("(//input[@id='environment'])[5]").Click
Tdate = Date
enddate = DateAdd("d", 3, Tdate)
driver.findElementById("startDate").SendKeys Tdate
driver.setImplicitWait 1000
driver.findElementById("endDate").SendKeys enddate
driver.setImplicitWait 5000
' driver.findElementByClas
'driver.findElementByLinkText("7").Click
'driver.findElementById("endDate").Click
'driver.findElementByLinkText("10").Click
driver.findElementByXPath(".//*[@value='0-5']").Click
driver.findElementById("turnOnNew").Click
driver.findElementByCssSelector("div.rightBtn").Click
driver.setImplicitWait 5000
driver.findElementByLinkText("DEQ Simulate Master").Click
driver.setImplicitWait 5000
driver.findElementById("btnAppSubmit").Click
driver.setImplicitWait 5000
' Worksheets("Sheet2").Cells(i, 2).Value = "done"
driver.setImplicitWait 5000
Worksheets("Sheet2").Activate
driver.setImplicitWait 5000
Worksheets("Sheet2").Rows("2:6").EntireRow.Delete
driver.setImplicitWait 5000
driver.setImplicitWait 1000
rw_cntx = Worksheets("Sheet2").Cells(Worksheets("Sheet2").Rows.Count,
1).End(xlUp).Row
rw_cnt = rw_cntx - 1
driver.setImplicitWait 5000
driver.setImplicitWait 50
Wend
Worksheets("Sheet3").Activate
row_cntx = Worksheets("Sheet3").Cells(Worksheets("Sheet3").Rows.Count, 1).End(xlUp).Row
Worksheets("Sheet3").Activate
Worksheets("Sheet3").Range("B2:B" & row_cntx).Value = "Done"
'Range("B2:B" & row_cnt).Value = "Done"
MsgBox "completed"
driver.stop
End Sub
Original comment by coolguy2...@gmail.com
on 13 Oct 2014 at 7:50
I found out that the javascript is not executed as intended on the open command.
I'll fix it for the next release. For now, a workaround would be:
driver.Open "https://....url....
driver.Open "javascript:'://'+document.getElementById('overridelink').click()"
I also had a quick look at your code and here is my advice:
> setImplicitWait should be set only once as it is a global command.
Use .findElementById("endDate", 3000) to set a specific timeout of 3sec for
this search.
and use .wait 3000 to wait for 3sec
> Locate an element only once if the page is not reloaded to improve the
performance:
Set eleAccNumber = driver.findElementById("accountNumber")
eleAccNumber.SendKeys keys.Enter
eleAccNumber.wait 500
eleAccNumber.SendKeys Accounts2
eleAccNumber.SendKeys keys.Enter
eleAccNumber.wait 500
...
Original comment by florentbr
on 14 Oct 2014 at 9:24
Now working in v1.0.21.1 :
driver.Open "javascript:document.getElementById('overridelink').click()"
Original comment by florentbr
on 14 Oct 2014 at 5:13
Original issue reported on code.google.com by
coolguy2...@gmail.com
on 10 Oct 2014 at 1:06Attachments: