Instead if Specifying the Wait Time - can we wait until the system responds

Rohith1324

Board Regular
Joined
Feb 27, 2018
Messages
114
Hi All,

Below is the script I'm running but "wait time" is giving me issues...when the webpage is loading fast...the script is getting executed successfully....but when it is exceeding the wait time then it is throwing an exception. ( it is very difficult to set one fixed time as the Web portal response is fluctuating )

Do we have any option to have the wait time assigned until the system responds. - Please help.




VBA Code:
For Each C In Range("A6:A" & Cells(Rows.Count, "A").End(xlUp).Row).Cells
        bot.Wait 2000
        bot.FindElementByXPath("//*[@id='createNewForm']/div[3]/div/div/button/span[1]").Click
        bot.Wait 500
        bot.FindElementByXPath("//*[@id='createNewForm']/div[3]/div/div/div/ul/li[" & C.Offset(0, 1).Value & "]/a/span[1]").Click
bot.Wait 1000
        bot.FindElementByXPath("//*[@id='createNewForm']/div[4]/div/div/button/span[1]").Click
        bot.FindElementByXPath("//*[@id='createNewForm']/div[4]/div/div/div/ul/li[" & C.Offset(0, 3).Value & "]/a/span[1]").Click
bot.Wait 1000
        bot.FindElementByXPath("//*[@id='createNewForm']/div[5]/div/div/button/span[1]").Click
        bot.FindElementByXPath("//*[@id='createNewForm']/div[5]/div/div/div/ul/li[" & C.Offset(0, 5).Value & "]/a/span[1]").Click
        bot.FindElementByXPath("//*[@id='custName']").SendKeys C.Offset(0, 6).Value
bot.Wait 1000
        bot.FindElementByXPath("//div[@class='ui-grid-cell ng-scope ui-grid-coluiGrid-000M']").ClickDouble
bot.Wait 200
        bot.FindElementByXPath("//*[@id='cpoNo']").SendKeys C.Offset(0, 7).Value
bot.Wait 200
        bot.FindElementByXPath("//*[@id='reqDesc']").SendKeys C.Offset(0, 8).Value
If IsEmpty(C.Offset(0, 9).Value) = True Then
        bot.FindElementByXPath("//*[@id='main']/div[2]").ScrollIntoView
        Else
        bot.FindElementById("uploadFileBtn").SendKeys C.Offset(0, 9).Value
        End If
        bot.FindElementByXPath("//*[@id='createNewForm']/div[15]").ScrollIntoView
If IsEmpty(C.Offset(0, 10).Value) = True Then
bot.FindElementByXPath("//*[@id='main']/div[2]").ScrollIntoView
Else
bot.FindElementByXPath("//*[@id='createNewForm']/div[13]/div/div[5]/div[1]/div/input[2]").Click
bot.FindElementById("uploadFileBtn_duplicate").SendKeys C.Offset(0, 10).Value
End If
        bot.FindElementByXPath("//*[@id='main']/div[2]").ScrollIntoView
        bot.SendKeys bot.Keys.Tab
        bot.FindElementByXPath("//*[@id='createFormsubmit']").Click
        bot.Wait 7000
        Set ele = bot.FindElementByXPath("//*[@id='statusModal2']/div/div/div[2]/p")
        C.Offset(0, 11).Value = ele.Text
        bot.FindElementByXPath("//*[@id='statusModal2']/div/div/div[3]/a").Click
    Next C
    MsgBox "All the work ID's are submitted Successfully"
End Sub
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
youll need try try this, do it on a copy
VBA Code:
For Each C In Range("A6:A" & Cells(Rows.Count, "A").End(xlUp).Row).Cells
        DoEvents
        bot.FindElementByXPath("//*[@id='createNewForm']/div[3]/div/div/button/span[1]").Click: DoEvents


if you add tasks together on the same line you need to specify the colon
 
Upvote 0
youll need try try this, do it on a copy
VBA Code:
For Each C In Range("A6:A" & Cells(Rows.Count, "A").End(xlUp).Row).Cells
        DoEvents
        bot.FindElementByXPath("//*[@id='createNewForm']/div[3]/div/div/button/span[1]").Click: DoEvents


if you add tasks together on the same line you need to specify the colon
even by adding doevents this is getting stopped after sometime...
 
Upvote 0
what does your modified code look like
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,199
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top