This is UltimateRPA Documentation
Internet Explorer

Controlling Internet Explorer

With UltimateRPA, you can operate Internet Explorer in the same way as any other application. For easier control, you may use an Internet Explorer specialised class AppExcel, which inherits the methods of the class App.

Running Internet Explorer

Run Internet Explorer using the urpa module function exec_ie_app. As an optional argument, you can pass a URL-containing string to the function. Internet Explorer opens and goes to the selected URL. If no argument is passed, Internet Explorer launches and its home page is shown.

import urpa
def main():
ie_app = urpa.exec_ie_app("https://playground.ultimaterpa.com/")
ie_app.set_auto_close(False)
IE_playground.png
Figure 1 Internet Explorer window with loaded page

If you run the above code, a simple UltimateRPA Playground website opens. The website is used in the following examples.

Website control

A website is controlled in the same way as other applications. Use Inspector to compose the expression. In Inspector, create the expression app.find_first(cf.button().name("Continue")).send_mouse_click() to activate the Continue button at UltimateRPA Playground. In the following code we use the variable ie_app instead of app for identifying the Internet Explorer app object. This allows you to modify the settings directly in Inspector, where you press the gear button and replace app with ie_app or add the prefix in the code. A Condition Factory object is used to call the functions to identify the Continue button.

import urpa
def main():
ie_app = urpa.exec_ie_app("https://playground.ultimaterpa.com/")
ie_app.find_first(cf.button().name("Continue")).send_mouse_click()
ie_app.set_auto_close(False)

For more details on how to control the application's features, see [Robot Interaction](@ ref)

Waiting for a page to load

When working with web applications, you come across situations where the pages load slowly and you need to make sure that the requested page is completely loaded before performing the next action. This is simulated using the website UltimateRPA Playground if you select the Delayed switch and press the Continue button. It then takes approximately six seconds to load the next page with the "Success" sign. You can use the following code to test this behavior.

import urpa
def main():
ie_app = urpa.exec_ie_app("https://playground.ultimaterpa.com/")
ie_app.find_first(cf.radio_button().name("Delayed")).send_mouse_click()
ie_app.find_first(cf.button().name("Continue")).send_mouse_click()
ie_app.find_first(cf.text().name("Success"))
ie_app.set_auto_close(False)

If you run the code above, you find that it ends with the error ElementNotFoundError. This is because, by default, the method find_first searches for the Success element for only five seconds, but the web application takes at least six seconds to load the page with the desired element. To allow the find_first method to wait for some more time until it gives up finding the element, we could increase its wait time. Or in this case, however, use the method wait_for_complete, which checks whether the page was fully loaded. It has an optional timeout argument, which is set to a default value of 5000 ms.

import urpa
def main():
ie_app = urpa.exec_ie_app("https://playground.ultimaterpa.com/")
ie_app.wait_for_complete()
ie_app.find_first(cf.radio_button().name("Delayed")).send_mouse_click()
ie_app.find_first(cf.button().name("Continue")).send_mouse_click()
ie_app.wait_for_complete(10000)
ie_app.find_first(cf.text().name("Success"))
ie_app.set_auto_close(False)

The method wait_for_complete may not work correctly if certain technologies or browsers are used. See the documentation for more information.

Navigating to a URL

To go to another URL, use the method navigate, pass the string with the URL that you want to open in Internet Explorer to the method as a parameter. Run Internet Explorer in a sample example. Internet Explorer opens on your home page. Wait for two seconds and navigate to the UltimateRPA Playground website.

from time import sleep
import urpa
def main():
ie_app = urpa.exec_ie_app()
ie_app.wait_for_complete()
sleep(2)
ie_app.navigate("https://playground.ultimaterpa.com/")
ie_app.wait_for_complete()
ie_app.set_auto_close(False)