Is find_element_by_accessibility_id function case-sensitive? - appium

Is find_element_by_accessibility_id function is Appium case sensitive or not.
If its case sensitive how can I find an element with "Bn1" ID with "bn1" text.

Related

Is it possible to add label field into device via Data Converter?

I would like to fill label and description fields without any manual work.
Or what is the best way for TB to fill those fields?
Label & Description in device
You should do it in the rulechain.
You should have in you rulechain tab the Root rule chain, add a script transformation node after the message filter one (you need to connect the two nodes with an Entity created tag if you want it to be done on every device).
to access the label and the description in the node you need "msg.additionalInfo.description" and "msg.label"
add the nodes to he existing root rule chain, and add an originator filter for device if you only want this to be done on devices
You can fill the Label via Data Converter ("deviceLabel" or "assetLabel" key). Description is not supported, yet.
Support was added in version 3.3.2:
https://thingsboard.io/docs/pe/reference/releases/#v332-november-11-2021
// Result object with device/asset attributes/telemetry data
var result = {
// Use deviceName and deviceType or assetName and assetType, but not both.
deviceName: 'Name',
deviceType: "Type",
deviceLabel: "Label",
attributes: {},
telemetry: {}
};

Is it possible to apply [Rule Chain] after [Data Converter]?

I am currently working on a POC by using ThingsBoard PE.
Our raw data contains [Asset] [Attributes].
Data flow:
[IoT cloud] --https webhook carry raw data--> [ThingsBoard PE HTTP INTEGRATION] --uplink--> [ThingsBoard PE Data Converter]
My question is: is it possible to apply [Rule Chain] after [ThingsBoard PE Data Converter]? Therefore, the device can auto create relationship with [Asset] by the [Attribute], instead of [AssetName].
Example data after data converter process:
{
"deviceName": "ABC",
"deviceType": "temperature",
"attributes": {
"asset_id": 6 // <-- the id is used in asset attribute
},
"telemetry": {
"temperature": 39.43
}
}
Answering your two, separate questions:
is it possible to apply [Rule Chain] after [ThingsBoard PE Data Converter]?
Yes it is possible. Once your data is successfully integrated and you are receiving it, you can access it using the [Input] Rule Node (the default green one that is always there when you create a Rule) and route it to any other node you need.
Therefore, the device can auto create relationship with [Asset] by the [Attribute], instead of [AssetName].
So, you want the relationship to take your custom attribute and use that as the pattern that identifies the Asset you want to create the relationship from.
The PE edition already has the Create Relation Node. However, seems that as it is one is not able to do what you seek (has no option to specify custom Asset id).
However, two options you got are:
Create a Custom Rule Node that does what you want. For that try checking the Rule Node Development page from Thingsboard. You can use the Create Relation Node as base and work from there. This can be a longer solution than doing...
Enrich your incoming message's metadata, adding your desired attribute. The Create Relation Node allows you to use variables on your message's metadata in your Name and Type patterns, as seen from this screenshot I took from that node:
This allows us a workaround to what you want to do: Add a Script Transformation Node that adds attributes.asset_id to the metadata, for example as metadata.asset_id, so you can then use it as ${asset_id} on your Name and Type patterns.
For example, your Transform() method of such Script Transformation Node should look something like this:
function Transform(msg, metadata, msgType){
//assumming your desired id is msg.attributes.asset_id, add it to the metadata
metadata.asset_id = msg.attributes.asset_id;
//return the message, in your case to the Create Relation Node
return {msg: msg, metadata:metadata, msgType:msgType};
}
Finally, your Rule should be connected like this:
[Input] -> [Script Node] -> [Create Relation Node] -> [...whatever else you like]

NativeScript-Dev-Appium : UIElement.text() / UIElement.getAttribute("value") returns the automationText instead of the text displayed

I am using NativeScript-Dev-Appium#5.0.0 and wish to check for the text displayed on a label. I have automationText property assigned to the and use Driver.findElementByAccessibilityId(automationTextValue) to get the element. The element is found, but when I try to use the UIElement.text() / UIElement.getAttribute("value") on it, it returns the value of the automationText attribute instead of the actual displayed text. Is there any other method to do it because I can't find any.
Unfortunately, this is a limitation of NativeScript itself since when the automationText property is used, it will set all properties of the element like value, name, label etc. I would suggest you set the same text to automationText property and then you can access or test the element using something like this:
Using XPath:
const el = await driver.findElementByXPath("//*[#name=\"My automation text\"]");
For Android only
const el = await driver.findElementByText("My automation text");
const text = await el.getAttribute("text");
Use imageVerification types like:
await driver.compareRectangle
await driver.compareElement
await driver.compareScreen
Which is very convenient but the cons here is that this will require higher maintenance at some point.

Accelerators and sendInputEvent

According to the Accelerator documentation, I should be able to send key commands like Ctrl+A and Return.
Using the following, I can send key commands one at a time:
//ch = current key command, like 'a' or 'Backspace'
webView.sendInputEvent({
type: 'keyDown',
keyCode: ch
});
webView.sendInputEvent({
type: 'char',
keyCode: ch
});
webView.sendInputEvent({
type: 'keyUp',
keyCode: ch
});
This works fine for ordinary letter keypresses, and even Backspace, but the above won't honor modifier combinations like Ctrl+A, or even some single modifiers like Return or Enter. If I enter text on a textarea and then send Return, I would expect a newline to be added to the textarea.
From the Electron documentation (emphasis mine):
keyCode String (required) - The character that will be sent as the keyboard event. Should only use the valid key codes in Accelerator.
It would seem by that documentation, the newline should get added.
Is that expectation correct? If so, what am I doing wrong?

Issue with using int.parse() in Dart

I'm currently teaching myself the Dart language, and my first app doesn't seem to be working right. Here's the code that's causing trouble:
usrLoc = int.parse(query("#txtLoc").text);
When I try to run the app, it opens fine, but when I click the button that triggers this (and three other similar parses), the debugger stops and tells me "Source not found" for int._native_parse(), int._parse(), and int.parse().
Any help would be greatly appreciated.
The text property for the specified element #txtLoc returns an empty string.
The parse method requires that:
The source must be a non-empty sequence of base- radix digits, optionally prefixed with a minus or plus sign ('-' or '+').
You can specify an onError named argument in your call to parse, which takes a callback that handles the invalid input. E.g., if you want the parse call to return the value 42 for all invalid input, you can do this:
usrLoc = int.parse(query("#txtLoc").text, onError: (val) => 42);
If you really expect the element to have some text, you can store the result of query("#txtLoc").text into a separate variable and verify the value. It would also be interesting to check what the real element type is or which tag is marked with id #txtLoc.
If you want to get the content of an input element, you should use the value property instead of text:
query("#txtLoc").value

Resources