'Robot Framework: Is It possible to combine libraries? Ex: Use Selenium and Appium libraries together on a mobile automation test

So, I want to use SeleniumLibrary's keyword Set Selenium Speed. which Sets the delay that is waited after each Selenium command, but I guess it's not possible, at best it would set a speed for Selenium commands, not the Appium ones, which are the ones I need to have a reduced speed.

Why is that? I am currently automating tests for registering in an Android app and I didn't found something similar to Set Selenium Speed in AppiumLibrary, but if I don't use a lot of Sleeps in between commands, Robot passes straight through some fields without sending text, and the test fails, I am basically searching for an alternative to Sleep.

Examplified bellow, in this code if I delete the Sleeps the test fails because doc field doesn't get filled:

Click Element  xpath=//*[@index='2']  # Doc field
  #Wait Activity  MainActivity  timeout=2  interval=2
  Sleep  1
  Input Text  xpath=//*[@index='2']  '41838086854'  # Send valid doc number
  Sleep  1
  Click Element  xpath=//*[@index='3']  # Password field
  Sleep  1
  Input Password  xpath=//*[@index='3']  asdQWE123!@#  #Send valid password
  Sleep  1  # Dá para usar o comando 'Click Text' tbm (experimentar depois)
  Click Element  xpath=//android.widget.Button[@content-desc=\"LOGIN\"]  #Login button
  Sleep  2
  Wait Until Page Contains Element  xpath=//android.widget.Button[@content-desc=\"GENERATE SECURITY CODE\"] 


Solution 1:[1]

Is there a reason why you are using sleep instead of Wait Until Page Contains Element?

A better approach is to write one keyword

Wait Until Element Exist And Click
    [Arguments]    ${element}
    Wait Until Page Contains Element    ${element}
    Click Element    ${element}

Wait Until Element Exist And Click
    [Arguments]    ${element}    ${text}
    Wait Until Page Contains Element    ${element}
    Input Text  ${element}  ${text}

Using Sleep in UI automation may be unstable and might not be the best solution for you.

If you want to make a time limit on waiting for the element's present then do this

Wait Until Page Contains Element    ${element}    timeout=5s

Using two libraries is technically possible but not recommended Since there are many repetitive keywords in both libraries, you will have to specify which keyword you are referring to when using them. For example you may have the following error message

Keyword 'Click Element' could not be run on failure: 
Multiple keywords with name 'Capture Page Screenshot' found. Give 
the full name of the keyword you want to use:     
AppiumLibrary.Click Element     
SeleniumLibrary.Click Element.

So, using more than one same purpose libraries on one project is generally not recommended.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1