how to find visibility of element / image in calabash - visibility

I am working on calabash android with the platform ruby.
And I have to find the visibility of an element / image and it has id and as well only one property ie., enabled , that too always true.
and i tried the options isVisible , isDislayed but am not sure these properties exists

First try this command
query("*")
If it shows element, then proceed with getting element using ID.
query("* css:'#id_name'")
The above line will display all the element with ID=id_name.
Note: It will show only visible element.
If you need to get all element(visible/hidden), you need use this code:
query("* all css:'#id_name'")

Related

Xamarin UItest query for similar elements

[Sceenshot][1]
[1]: https://i.stack.imgur.com/c5pkY.pngstrong text
I am trying to locate two similar elements ("Meer info"). On a previous build of the same app it works with this query:
_bewering1_helpbutton = x => x.Marked("De volgende gegegevens zijn bij ons bekend").Sibling("ImageRenderer");
Now this query gave 0 results. I think the reason is that our developer has changed the code in some places.
Is there any other way I can locate the elements "Meer info". It is not possible to use "Index" because on some small screens the locators are not visible at the same time.
I notice your REPL
You can use id to locate the elements "Meer info".
For testing, I use two Entrys, here is REPL
when I tab it, I enter the new value to it with
app.EnterText(c=>c.Marked("NoResourceEntry-2"), "1234567890123456")
Here is running GIF.

XPath - get a button inside another element with class

I need to find a button element using XPath. The problem is, the button has no unique identifier like Id or name, but is located inside another element which has a unique class (i.e. a class that no other element on page uses). I know how to get to that element and identify it by class but I don't know how to access the button inside that element.
.//mat-header-cell[#class='mat-header-cell cdk-column-delete mat-column-delete ng-star-inserted']
Any suggestions?
SOLUTION I FOUND:
Just added '//button' to the end of xpath and it works now!
.//mat-header-cell[#class='mat-header-cell cdk-column-delete mat-column-delete ng-star-inserted']//button

What will be xpath of attached screenshot appium- robot framework

I Want to find out xpath of login button from attached screenshots.
I have tried
Wait Until Page Contains Element xpath=//android.view.View[#content-desc='Login']
This return successful for finding element
but it does not click with below line of code
Click Element xpath=//android.view.View[#content-desc='Login']
Maybe you need to check if element is available, for example with:
Wait Until Element Is Visible xpath=//android.view.View[#content-desc='Login']
Or
Wait Until Element Is Enabled xpath=//android.view.View[#content-desc='Login']
I have attached screenshot after performing above steps.please check...

How to select a specific element inside editor (tinymce 4.x)

I have an image inside the editor using plugin 'imagetools' and added an additional image operation on it (that works fine). After this custom operation is done I'm loosing the selection of the image, that I try to select again.
Since the image is initally selected I would have the chance to capture some information to select it again after custom image operation. But whatever I try it doesn't work:
Before operation (while the image is selected by user):
var node = tinymce.activeEditor.selection.getNode();
After operation:
tinyMCE.activeEditor.dom.select(node);
-> nothing selected
tinyMCE.activeEditor.selection.select(node);
-> Error: Argument 1 ('refNode') to Range.setStart must be an instance of Node
I assume the solution is pretty simple. I just don't get it and tinymce documentation is not really helpful on this.
Found it: You can set a bookmark before doing any changes on or inside the element:
var bookmark = tinymce.activeEditor.selection.getBookmark();
After element processing you set back the bookmark:
tinymce.activeEditor.selection.moveToBookmark(bookmark);
Now your previously selected element should will be selected again.

How to set a span value with capybara?

Does anyone know how to set a value to span tag using capybara?
I tried using element.set or element.send_keys, they only selected the targeted element without modifing the previous value.
<div data-offset-key="bbpvo-0-0" class="_1mf _1mj"><span data-offset-key="bbpvo-0-0"><span data-text="true">aa</span></span></div>
HTML snippet is above, I want to set aa to bb.
Capybara is designed to emulate a user - A user can't edit a span unless there's some sort of javascript widget attached to it. If you have a JS widget attached to the span you would need to perform whatever actions a user would do in order to edit the span. So you say the user has to click on the span and then type on the span - if that is so then you could try something like
span = find('span[data-text="true"]')
span.click
span.send_keys("new content", :enter) # if enter is needed to end the editing
which may work - although I'm going to guess the element actually gets replaced with an input or something after it's clicked on, in which case you need to figure out what those elements are (using the browsers inspector) and then find and use send_keys or set on that element instead
To set text in span value,jquery can be used with capybara as shown below:
page.execute_script("$("<span css selector>").text("testing")");
or
page.execute_script("$("<span css selector>").html("testing <b>1 2 3</b>")");

Resources