How To Use Selenium And Appium Library Together

I’m trying to write automation tests for an application which has both web application and mobile application(android and ios). For web, I’m using SeleniumLibrary and for mobile i’m using AppiumLibrary.

So I have started creating keywords however i’m seeing keyword conflicts between SeleniumLibrary and Appium Library as both has keywords with same name.
Is there a way to import these libraries dynamically so that if i run tests related to web application, SeleniumLibrary should be used and AppiumLibrary when tests related to android or ios are run

As the error indicates, if you prepend the library name to the keyword it can then distinguish between which keyword from which library you are intending to use.

I see we could have a larger discussion about how one uses these two libraries together in ways that it doesn’t make it difficult or needed to specify every time which library you are meaning.

You could use https://robotframework.org/robotframework/latest/libraries/BuiltIn.html#Set%20Library%20Search%20Order when using both libraries. This way you can target the first library directly and the second library with the name in front. Ex: SeleniumLibrary.Wait Until Page Contains

Since most of keywords of both libraries have same names you will need to specify the library each time you use a keyword that exist in both Selenium & Appium

Here is an example:

AppiumLibrary.Wait Until Page Contains 
SeleniumLibrary.Wait Until Page Contains 

( I recommend to do it for all keywords )

1 Like