Navigate to url if browser got no internet it went to next url. how can i throw system exeption in uipath

In list of urls i will take one by one. while using navigate to url if browser got no internet it went to next url. how can i throw system exeption if there is no internet in UiPath.
-in excel there is some urls.
-taking one url for extact info by using for each row in datatablei use navigate url there is if codition if element of site exiest ten do else pop log no info but here i that urls ther is some different urls for avoidin them i use element exiext but it taking no internet element exiest as false and continue to next url.

note:here urls are some for element exiest data and some are different

What do you see in the browser when you try to navigate to a page but have no internet access? Use Check App State to check for that before going to the next item.

I have some bulk data with urls in that in that I want some element exist urls only remaining urls need to be status as don’t.but here when I’m runing bot I will turn off my inter net then it take as bad url which is element is not exist but it was no internet .it was continuous to next url.without sending any system exception.how can I give system exception for no internet.

Hi @LOHITH_KUMAR_SAKA

You can try ping the site to check if there is response then decide what you want to do based on it and check if this works for you

Try
   
   Dim request As System.Net.WebRequest = System.Net.WebRequest.Create("https://www.google.com")
    	request.Timeout = 5000 
    Dim response As System.Net.WebResponse = request.GetResponse()
    	response.Close()
    	Connected = True 

Catch ex As Exception
    Connected = False 
End Try

Cheers

Do you expect the internet connection to fail while running the automation?

Again I ask, when you turn off your internet and try to browse to the URL, what do you see in the browser?

but it avoiding urls also which is different urls

@LOHITH_KUMAR_SAKA

You can pass the URL as argument

Try
   
   Dim request As System.Net.WebRequest = System.Net.WebRequest.Create(URL)
    	request.Timeout = 5000 
    Dim response As System.Net.WebResponse = request.GetResponse()
    	response.Close()
    	Connected = True 

Catch ex As Exception
    Connected = False 
End Try

Are you able to get a selector for the “No internet” text on the screen? Use Check App State, click indicate, and see if you get UI elements from the browser that will identify you’re on the “no internet” page.

One thing to keep in mind with this is it’s a good start but it won’t differentiate between different reasons for failure. What if it’s just a bad URL? DNS issue? Internet access is working but the web server is down?

Error ERROR Validation Error BC30451: ‘Connected’ is not declared. It may be inaccessible due to its protection level. Variable ‘Connected’ is missing. Please use Data Manager to recreate it. Framework/Process.xaml

if i declered it was not taking condition


when i stop internet for get that element .i cant indicate browser

Strange. Maybe try OCR Text Exists and don’t give it a selector. I think it’ll just look at whatever is on the screen.

Ocr text exist also same issue

Hi @postwick

Yeap. I completly agree with you. The suggestion is a start point. We do not expect the internet connection to fail while running automation. But almost possible reasons to fail the result at the end is the same… BAD URL will break when try to navigate to it. DNS issue the same will occur etc. So if the case need to identify the root causes, even we using UI we need elaborate a good error handling mechanism

Another approach is not use dynamic URL to check the internet connection and use a fixed and stable one like google.com instead

What do you think?


sample flow

This appears to work. Use Take Screenshot and don’t give it a selector, output as image into a variable, then pass that variable into Tesseract OCR (or whatever OCR you want to use). Make sure (if you’re using Tesseract) to check “ExtractWords” and put a string variable into the Text output property. Then you can check the resulting text for the words “no internet”

Usually the way I do this would be…

screentext.ToUpper.Contains(“no internet”.ToUpper)

I just use the ToUppers to make sure false negatives occur due to differences in case.

Hi @LOHITH_KUMAR_SAKA

Following the automation skeleton using single url (google.com). Check if it works for your use case and keep in mind the points mentioned by @postwick

CheckInternetConnectedPingMethod.zip (5.7 KB)

1 Like

I wholeheartedly second this. Always start with the core process, not the repetition. Add the repetition later after you have the core process worked out.

I even have a test project I use to code granular steps then copy/paste the activities to the actual automation. It keeps your actual project tidier because you’re not doing any trial and error there. This methodology also lends itself to organized variables and scoping - when you paste the activities into your actual project, the variables will be missing. So you go down each activity and add the variable you need. Doing it this way keeps the scope as low as possible, and then you can adjust it upwards if needed.

Note that after copying the activities from your test project over to your actual project, copy the files from .screenshots too - then the activity screenshots will appear properly.

Try using image exist probably it may work.
Cheers.