How do you find the current platform in robotframework? - robotframework

I'm trying to find a Keyword or automatic variable that contains the current platform that the robot framework suite is being run on.
I assume it must know to allow it to access the file system.
I wanted to use this to load variable resources depending on the current platform

You can use the Evaluate keyword to get the platform from python using sys.platform:
*** Test Cases ***
| Example which logs the current platform
| | ${platform}= | Evaluate | sys.platform | sys
| | log | ${platform}
The exact values that are returned are documented in the sys.platform documentation.
For more fine-grained information, such as processor type, you can use the platform module in a similar manner.

Related

How to design a repository writing to pub/sub and reading from database in clean architecture

I want to design my application which requires writing asynchronously through pub/sub and reading synchronously from the database. How do you implement this in clean architecture? There's a separate process reading from the pub/sub and writing to the database.
I'm thinking of a design like this; however, I wasn't sure if it's a good design for one repository to be implemented using separate persistent infrastructure for reading and writing.
Repository | Controller | Infrastructure
my repository ---> my controller ---> (write) pub/sub
\-> (read) database
An alternative could be CQRS, but in my case, I use the same model for reading and writing, so I think it's better to use a single model.
Background:
Writes to my application are very elastic, while reads are consistent. So I avoid getting my service overloaded by writing asynchronously.
Thanks!
It the same as with any other clean architecture application.
+------------+ || +----------+ +------------+
| Controller | ---> | Use Case | ---> | Repository |
+------------+ || +----------- +------------+
|| | save() |
|| | find() |
|| +------------+
|| ^
============================================|==========
|
+------------+
| RepoImpl |
+------------+
| save() | ---> write to pub/sub
| find() | ---> read from db
+------------+
Maybe you split up the repository writes and reads into different interfaces, because you might have a use case that only reads and another that only writes.
I usually apply the interface segregation principle and define use case specific interfaces.

How to send token in CoAP requests?

Is there a consensus on how to send tokens as part of CoAP requests?
HTTP clients share their identity/credentials through the Authorization header (or eventually the Cookie header) or less often as part of the URL (e.g. a JSON Web Token encoded in base64url). In the CoAP RFC, there is not equivalent option to Authorization.
Draft profiles for authentication and authorization for constrained environments (e.g. OSCORE or DTLS) rely on the underlying security protocol to maintain a stateful connection and the token is uploaded to /authz-info once:
C RS AS
| [-- Resource Request --->] | |
| | |
| [<---- AS Request ------] | |
| Creation Hints | |
| | |
| ----- POST /token ----------------------------> |
| | |
| <---------------------------- Access Token ----- |
| + Access Information |
| ---- POST /authz-info ---> | |
| (access_token, N1) | |
| | |
| <--- 2.01 Created (N2) --- | |
However, this is not suitable for unprotected environment (e.g. for development or in a private network). Since CoAP is typically on top of UDP, it is not possible to have "sessions" so we cannot track which client uploaded which token. I'd like to avoid to discuss about usefulness of token in unprotected context.
Should the token be part of the URI (i.e. as a Uri-Query option or in the Uri-Path)? ThingsBoard is an example of service having the the token as part of the Uri-Path but I'm not sure if this is the best option. Also, would sending a binary CBOR Web Token in Uri-Query be possible without base64url encoding?
In CoAP, no attempt is made to provide user authentication without a security layer in place, nor are there provisions for sessions in the CoAP layer (which would violate the REST design).
As I understand, that was a conscious decision to guide implementers towards a RESTful design, and to avoid the transfer of security tokens over unsecured transports.
For the two use case of "during development", it is possible to introduce an own CoAP option in the experimental-use range, for example "65003 = Simulated-OSCORE-Key-ID" (where 65003 is chosen to be critical and not safe to forward). While the OSCORE stack is not operational, an ad-hoc made-up OSCORE key ID could be inserted there and then have a token POSTed using it in the ACE steps. Obviously, those constructs should neither make their way out of a test setup, and not into specifications.
Private networks are considered as untrusted ("NoSec mode") as the rest of the network in CoAP. That assumption can probably be understood better in the context of the principle of least authority, which makes setups where all devices (and processes) on a network share the same set of permissions highly unlikely.

Robot Framework : Is there any way using which we can execute test cases (same test cases/test suit) on multiple andriod devices at once?

enter image description hereOnce the app is launched on multiple android devices. How can we execute same test cases on multiple mobile devices at once? As I am having a bunch of test cases to execute on multiple android devices. I am trying to use For Loop by passing udid OR Appium Server name in Test cases,but it's not working.It executes test case on a single device only.Is there any way using which we can execute test cases (same test cases/test suit) on multiple Android devices at once?
You could use https://github.com/mkorpela/pabot with --argumentfile[NUMBER] options.
What you basically want to do is Parallel execution of your tests. There are many tools available to achieve this with ease and much coverage (vast number of devices and flavors) like SeeTest Cloud, Xamarin Test Cloud, AWS Device Farm, Perfecto etc
However if you want to achieve using Appium and TestNG it is still possible. Below are high level steps:
Launch multiple instances of Appium server, by using different
address, port, callbackPort, and BootstrapPort as part of node
command.
Get the UUID of the devices and pass it in TestNG xml
Run the xml as suite.
Below is the link with exact commands and steps:
http://toolsqa.com/mobile-automation/appium/appium-parallel-execution-using-testng/
You can use something like following as solution to your problem. As I had said earlier in my answer, you can save the drivers in a dictionary &{drivers} and use it in your loop to do repetitive actions on all your devices.
*** Settings ***
Library AppiumLibrary
Library Collections
Library Process
*** Variables ***
${APPIUM_SERVER1} http://127.0.0.1:4723/wd/hub
${APPIUM_SERVER2} http://127.0.0.1:4750/wd/hub
${udid_device1} udid of device 1
${udid_device2} udid of device 2
*** Keywords ***
setup and open android phone A
&{drivers}= Create Dictionary
${androiddriver1}= Open Application ${APPIUM_SERVER1} platformName=android platformVersion=7.0 deviceName=android udid=${udid_device1} automationName=uiautomator2
... appPackage=com.android.contacts newCommandTimeout=2500 appActivity=com.android.contacts.activities.PeopleActivity
Set To Dictionary ${drivers} ${udid_device1}=${androiddriver1}
Set suite variable ${drivers}
setup and open android phone B
${androiddriver2}= Open Application ${APPIUM_SERVER2} platformName=android platformVersion=7.0 deviceName=android udid=${udid_device2} automationName=uiautomator2
... appPackage=com.htc.contacts newCommandTimeout=2500 noReset=True appActivity=com.htc.contacts.BrowseLayerCarouselActivity
Set To Dictionary ${drivers} ${udid_device2}=${androiddriver2}
Set suite variable ${drivers}
Log Dictionary ${drivers}
Open URL
:FOR ${key} IN #{drivers.keys()}
\ ${value}= Get From Dictionary ${drivers} ${key}
\ Log ${key}, ${value}
\ repetitive actions here
you can save sessions from open application in a dictionary and use them in a loop to do some actions on every phone.
Please edit your question with code for further help.

Why since Android 6 I can't delete a file located on a USB key with SAF?

I use SAF to access files on a USB key. Since Android 6 it is impossible to delete a file by the delete method of an object FileDocument. Why ?
Use DocumentFile.html#delete(). If that failed then please post exception or error message.
Also, did you send Intent with ACTION_OPEN_DOCUMENT or ACTION_OPEN_DOCMENT_TREE?
Depending on which action you're using you'll need to request at least Intent.FLAG_GRANT_WRITE_URI_PERMISSION, i.e.:
intent.addFlags(
Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION
| Intent.FLAG_GRANT_PREFIX_URI_PERMISSION
| Intent.FLAG_GRANT_READ_URI_PERMISSION
| Intent.FLAG_GRANT_WRITE_URI_PERMISSION

How can I get and store the user ID from the URL in a Selenium test?

I'm recording Selenium tests using Selenium IDE to test the registration flow of my drupal site, which depends heavily on the rules module.
Some of the tests involve the registration of user accounts. Since I will be using these tests on multiple servers with different amounts of users, I do not know upon starting the test which user ID to check for. Since the user ID is in the URL, I was hoping to grab it and store it in Selenium.
Upon logging in, users are redirected to a URL like http://192.168.100.100:8888/en/user/6, where "6" is the UID.
I imagine that I could use Selenium's storeValue command to do this, but what should I put as the target to pull the user ID out of the URL?
store | http://192.168.100.100:8888/en/user/6 | string
store | 1 | delimiter
store | javascript{storedVars['string'].split('user/')[storedVars['delimiter']]} | result
echo | ${result}
Or
storeLocation | string
store | 1 | delimiter
store | javascript{storedVars['string'].split('user/')[storedVars['delimiter']]} | result
echo | ${result}
Result will be 6
You could do this by grabbing the url and parsing the string for the user ID if you are using RC or Selenium 2.
For specific help you'll have to shed some light on what version of Selenium you are using (IDE, Selenium RC, Selenium 2/Webdriver) and what language?
If you have a sample URL string you can get a more exact answer as well.

Resources