how to use index find element for android appium - xpath

I am testing my Android application using Appium + robot framework.
because an android screen that doesn't have ids for these elements.
So I used the xpath to find the elements then I can find the index1 success but index[3] can't find.
This is how the screen looks like in UI Automator Viewer:
my xpath:
input text xpath=//android.widget.EditText[1] xxx
input text xpath=//android.widget.EditText[3] xxx
Would appreciate any help.

xpath=//android.widget.EditText[2]
The xpath reads "find all android.wdiget.EditText and return the n-th matching node - in your case, the target one is the 2nd in the nodeset; you've mistaken the condition as the n-th chield of the parent node.
Plus, the position in xpath start from 1, not 0.

Related

Select elements based on layout in Cypress

I am looking for a solution that can work like the following code in Playwright.
page.click('input:right-of(:text("Username"))');
By using this command in Playwright, the input element on the right side of text Username will be clicked. I searched for a while but found that there seemed to be no handy equivalents in Cypress. Are there any approaches that can enable the possibility to select elements based on their positional relationships?
I think you can use
cy.contains('Username') // === :text("Username")
.next() // === :right-of(<previous subject>)
.click()
There may be subtle differences, like .contains() is a partial match and .next() is the next sibling in the DOM, not necessarily "right-of" by x coordinates.
You can add-in cypress-testing-library which has
cy.findByLabelText('Username').type('myname')
I haven't used it, but semantically seems to be what you are aiming for. Would be useful if relative positions change in mobile mode (e.g labels above).
A while back I implemented custom commands to assert relative positions of elements, as we were getting a lot of CSS regressions, but it's quite fiddly.

How do I find the hexidecimal hash string of an element in Appium iOS?

I am currently trying to figure out how to tell appium to scroll a specific element in an app in iOS simulator. I'm following this documentation
In the arguments available for the mobile: scroll functionality, it states the following:
element: The internal element identifier (as hexadecimal hash string) to scroll on. Application element will be used if this argument is not
set
I can't find any documentation on how to find or identify the hexadecimal hash string of an element in Appium. Any recommendation of how I can accomplish this? I am using the webdriver.io framework with Javascript.
This is pretty easy. You just need to call .getId() to get hexadecimal id of the element.

UIPath Robot won't type into a text box, clear selector. Clicking separately and sending hotkeys also does not work

I've tried nearly anything, The "Type Into" activity won't print plain text into the text box let alone a held variable. The textbox element in question is the update work items comment box in the acme-test website from the Level 3 RPA developer course. I am able to type into the box manually and the robot is able to find it (the cursor moves to the centre of the text box and the program continues). I've tried quite a lot, including using a click activity and then sending the string as hotkeys.
Most probably the issue is related to your selectors. Since you are on level 3 RPA developer course I assume you are using Reframework for the task and I believe because of comprehensive error handling capabilities of this template your application just continuous with the next item instead of crashing when it can't find the element.
To solve the selector issues I usually do the following:
Use partial selectors instead of full selectors
Use wildcards for dynamic parts of your selectors (* for replacing any number of characters, ? for replacing exactly 1 character)
You can also store the page you are working on in a Uipath.Core.Browser type variable to eliminate the need of reselecting browser.
Also keep in mind that if you have used basic recorder functionality of UI path it generates full selectors.

XCTest - how to handle scrolling of list

I am using xcode 8.3.3, swift, and XCTest. I am wondering what the best approach to handle scrolling is when you plan to run your tests against multiple simulators and have a list displayed. Since the screen size may change based on the simulator being used, the element you want to select to scroll up on may or may not be displayed.
If I have a list with x # of elements, how do I best approach which element to use to scroll the list up to have the next set of elements displayed on the screen so that the tests will run on multiple simulators of different screen sizes?
When we do "po XCUIApplication()" we see all the elements in the list, so in order to know which one is the last one displayed on the screen, we would have to look through each element and do a checked like isDisplayed or something to find the last element currently displayed ... but I was hoping there is a better approach?
If the element you want to use is displayed when you do po XCUIApplication() then you should just be able to tap() it without having to scroll it into view. The framework will handle the scrolling automatically if it can find the element.
Here is an article I wrote discussing how to use SBTUITestTunnel for scrolling:
https://rlukasik.medium.com/using-sbtuitesttunnel-for-scrolling-in-xcuitests-2e166440ca73

Google places autocomplete with Selenium IDE test

I'm trying to make test in Selenium IDE (from Firefox addon) for autocomplete place (given from google places). I need type in input place name and get the first location.
Sequence for place "Rzeszów, Polska":
i.stack.imgur.com/gqRMd.png
Firstly I've tried mouseOver and Click action - elements exists but didn't make a click on autocomplete. Next I've tried two another sequences (with clickAt and KeyDown), but also didn't make a click, despite the fact that Selenium can find correct locator.
i.stack.imgur.com/F13q7.png
I was trying my solution for jQuery autocomplete -> jqueryui.com/autocomplete/ and it worked fine there.
I think, problem is connected with html structure, with bold in place name:
i.stack.imgur.com/BfLyE.png
You can test it on: jsfiddle.net/dodger/pbbhH/
My sequence in Selenium IDE (shown above) doesn't work for google places, could anyone solved this problem with autocomplete?
//Moderator: Please add photos and create links to my post and delete this line. Thanks.
To force the places autocompletion list to appear I had to send single keydown and keyup events to the input field. Like this:
selenium.focus(LOCATOR);
selenium.type(LOCATOR, ""); // clear the field
for (int i=0; i<value.length(); i++) {
String c = String.valueOf(value.charAt(i));
selenium.keyDown(LOCATOR, c.toUpperCase());
selenium.keyPress(LOCATOR, c);
selenium.keyUp(LOCATOR, c.toUpperCase());
}
Finally, to select an entry of the list, I've got it working by simulating keyboard events (since I also had no luck with mouse events).
keyDown with the arrow down key: selenium.keyDown(LOCATOR, "\u0028");
blur on the input field (optional I think): selenium.fireEvent(LOCATOR, "blur");
LOCATOR is the locator for your input field. \u0028 is the key code for arrow down (hex 28 or dec 40)
Hope this helps.

Resources