Skip to main content
Version: 10.2.4

Apply universal RPA driver

The universal driver provides the following benefits for rapid RPA scripts development:

  • You do not need to switch between drivers and create multiple robot plugins.
  • You can use the universal driver in 99% of Use Cases. Almost all RPA Use Cases don't need complex driver-juggling with transactions handling and support.

To use the universal driver, complete the following conditions:

  1. In the robot plugin, set the driver="universal" attribute.
  2. Add a capability inside the robot plugin: <capability name="SEARCH_ALL_WINDOWS" value="true" />
Expand to see the universal driver example
<?xml version="1.0" encoding="UTF-8"?>
<config xmlns="http://web-harvest.sourceforge.net/schema/1.0/config" scriptlang="groovy">

<robotics-flow>
<robot driver="universal" close-on-completion="true" start-in-private="false">
<capability name="SEARCH_ALL_WINDOWS" value="true" />
<script><![CDATA[

// opening Notepad
openAndFocus("notepad.exe", 3000, 250);
sendKeys("What is RPA?");
pressEnter();

// opening Firefox browser
openFirefox("https://www.wikipedia.org/");
$(byXpath("//input[@id='searchInput']")).val("Robotic process automation").pressEnter();
def wiki_text = $(byXpath("//div[@id='bodyContent']//p")).getText();

// switching back to Notepad
window("[CLASS:Notepad]");
sendKeys(wiki_text);
pressCtrlA();
pressBackSpace();

]]></script>
</robot>
</robotics-flow>

<export include-original-data="true"></export>

</config>
tip

For more universal driver examples, see:

Set driver type in universal driver explicitly​

While using the universal driver in complex Use Cases, the driver auto-switching algorithm can fail to automatically detect which application (web or desktop) should accept the current action, for example:

$(byXpath("//input[@id='searchInput']")).click()                 // web

switchTo().window('[CLASS:SunAwtFrame; TITLE:SwingSet2]')
$(byXpath("//*[@text='Eyes']/following-sibling::*")).click() // desktop

To handle such cases, use an explicit driver switching methods that accept a closure with all actions for this driver:

  • inDesktop{}
  • inChrome{}
  • inFirefox{}
  • inEdge{}
  • inIE{}

For instructions that are outside the closure, the default auto-switching mechanism is applied.

The explicit driver closures improve the stability and readability of your code.

Using driver type closures
<robotics-flow>
<robot name="universalDriver" driver="universal" close-on-completion="true">
<script><![CDATA[

// open a web-application in Firefox and log in
inFirefox() {
open('https://invoiceplane.workfusion.com')
$('#login').click()
$('#email').val('wf-robot@mail.com')
$('#password').val('freedom4ROBOTS')
$(byName('btn_login')).click()
}

// open a web-page in Chrome and click
inChrome() {
open('https://www.w3schools.com/')
switchTo().frame('iframeResult')
$('#demo h1').shouldHave(text('XMLHttpRequest'))
$(byText('Change Content')).click()
}

// open a web-page in Internet Explorer, enter text, and click
inIE() {
open('http://rpa-grid.s3.amazonaws.com')
$(byXpath('//input[@name='name']')).sendKeys('test')
$(byXpath('//button[@type='submit']')).click()
}

// open notepad and type text into it
inDesktop() {
open('notepad.exe')
switchTo().window('[CLASS:Notepad]')
sendKeys('foo')
}

]]></script>
</robot>
</robotics-flow>

Generate universal driver code in WorkFusion Studio​

To view an example of an RPA Bot task with the universal driver, do as follows:

  1. Create a new recording in RPA Recorder.

  2. Click Export code to Bot Task.

    As a result, a valid Bot Task with the universal driver is generated: