As, you can see in the above snippet, when i try to locate value e.g.. '16' in this case or i would like to scroll to select any other value. I am unable to select or scroll from this window. Is it possible to select value using robot framework with appium library. suggestions are most welcome.
One approach you can follow to do this is as follows:
First get the position of the element which is visible(In your case 16).
If you want to scroll down click on the element above 16 by substracting some pixels from the location you get in step 1.Verify for the element you want is highlighted or not.
Related
I'm starting to automate a test suite for a mobile app coded in NativeScript (it used to be a hybrid Cordova app) and it's proving difficult to locate some elements.
I'm trying to locate a TextView widget that's outside of the visible screen space (AKA viewport) using UiSelector:
#AndroidFindBy(uiAutomator = "new UiSelector().textContains(\"CFT\")")
private MobileElement labelCFT;
When I try to interact with such element, the result is the following message:
org.openqa.selenium.NoSuchElementException: Can't locate an element
by this strategy: By.chained({By.AndroidUIAutomator:
new UiSelector().textContains("CFT")})
The logic conclusion would be that the element does not exist or my locator strategy is faulty. But here is the thing, when I change the text to find for that of an element that's inside the visible space/viewport, the locator works flawlessly. Example:
#AndroidFindBy(uiAutomator = "new UiSelector().textContains(\"loans\")")
private MobileElement labelCFT;
And then:
public void whatText() {
System.out.println("Text of the label: " + labelCFT.getText());
}
I get the correct "Text of the label: These are your loans".
Apparently, it's a limitation of the UiSelector or at least the way Appium works with it.
The only option I imagine is to scroll the whole screen and then trigger #AndroidFindBy, then repeat until there's no scroll left.
Is this suppose to be how UiSelector and textContains() work?
Is it another solution for this?
Many thanks.
I have faced similar type of problems in automation. The only way around I found was to scroll up or down till the element is visible on screen and then access the element by "name". you can use the following command for scrolling.
driver.findElementByAndroidUIAutomator("new UiScrollable(new UiSelector()).scrollIntoView(text(\"Your Element\"));");
After your desired element is visible on the screen you can access that element easily.
Thanks
In Android App you can only click or do any actions on the elements which are visible on the screen if you want to perform any actions on element which are not visible you can use touch action method where you need to specify x and y cordinated i think this might help you in my case this works
TouchAction ta = new TouchAction(driver);
ta.press(PointOption.point(207, 582)).moveTo(PointOption.point(8, -360)).release().perform();
I have a close button on a ViewController that is being presented as a ChildViewController. I have this button's accessibility turned on and the accessibility identifier is closeButton. This button does not have any text, it just has an image.
I am attempting to test the presentation and dismissal of this view, but am running into an issue, the XCUITest cannot find the element. My test code is:
app.buttons["PresentChild"].tap()
XCTAssertTrue(app.otherElements["ChildViewController"].exists)
XCTAssertTrue(app.buttons["closeButton"].exists)
The first assert passes, but the second assert fails.
I tried to do the "Record UI Test" to select the button to have it be automatically generated, but then I just get an error saying Failed to find Matching Element. I tried erasing all the content on the simulator and deleting all derived data, and that didn't work either.
Does anyone know a workaround to this obvious bug in Xcode? I can't access the element through the recording, I can't access the element through the accessibility feature, I have zero idea how else to access this button.
I don't know what is the exact problem with your assertion. But this steps may help you.
Put a breakpoint on this line XCTAssertTrue(app.otherElements["ChildViewController"].exists)
Now run the test case. When the control reaches this line, type this line in the debugger po XCUIApplication().buttons.debugDescription then tap the enter button
It will print all buttons in your current view. Now check whether the "closeButton" exists in that list
If it exists, check the identifier name. Make sure that it is "closeButton" (Identifier is case sensitive, also spaces in the identifiers matters)
If the identifier is right, try to find out the closeButton's exact view hierarchy. Means, instead of just checking like app.buttons["closeButton"].exists, try like app.navigationBars.otherElements["someName"].buttons["closeButton"].exists
(This seems funny, but giving the exact location path of the element is a good practice, and it will work sometimes)
Note: This error "Failed to find Matching Element" on UI recording will happen if the system can not locate the element with proper identifier while doing action on it. So my guess is, your closeButton does not have proper identifier or it is not added to the current window.
Cheers!!
So I have my app set up with two view controllers. The first one is my initiation screen, where the app starts, and the second is one the user can navigate to. I added the second one later on in my development, but when I went to the right column under the identity inspector, my new Cocoa Touch Class file is not populated for me to select. Now if you ask me to just type it in, I've tried that, it does not seem to connect. I've tested it by printing a simple line in the viewDidLoad() of the new second class when it is loaded in the simulator, but nothing is printed. Any help would be greatly appreciated!! Thanks!
EDIT
Easy fix is:
Select the activity indicator on storyboard and go to identity inspector and copy the object id. as image: ObjectID_ActivityIndicator
Right click the storyboard file which has the view controller you are working at.
Open as > Source Code
Press command + F to find and look for the id you copied previously
Paste this: customClass="yourclassname" customModule="moduleNAme" customModuleProvider="target"(don't change this target word, you can choose desired module from identity inspector if any).
Command + S to save it and again right click on storyboard file > openAs> Interface builder
Now select activity indicator again and go to identity inspector. You will now see it there. You can also change it as per requirement.
Enjoy. I faced this problem today and found no help online. My class and module field were greyed out. Tried this fix and it worked.
Note: Make sure your custom class is accessible and is in app directory i.e it's not highlighted in red color but gives a normal look.
I have seen a problem like this where the solution was to change the "Module" to a specific value, close the storyboard, reopen it and delete the "Module" setting (assuming it was originally blank or restore it to its original value). This happened in project with many targets and their names may have changed.
I have UITableViewCell which has Subject,Name,Description,time. When I am testing this on Appium the xpath changed for UIElement for Subject line only.
xpath:-subject line: //UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[3]**/UIAStaticText[2]**
after changes
xpath:-subject line: //UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[3]**/UIAStaticText[3]**
Which is giving another UI element details, which fails the testing. How to handle this from Appium, or do I need to fix it from Xcode?
Basing on xpaths is not a really good idea.
But sometimes it is the only way to develop your scripts if there are no static ids nor accessibility labels available.
Your element that was previously set as: UIAStaticText[2], so as I suppose it was second element available at current screen. Now looks like UIAStaticText[3] - it is marked as third. If you are not able to see changes on the screen that you are automating, that can be caused because of an element that is under in the background it can be hidden.
The best approach will be with using static resource id's in your scripts or accessibility labels which you have mentioned in comment you've them already set and available.
I am new to IOS development. I am developing an app for IOS 8 devices. I used storyboard for my design yesterday my storyboard showing all UI design but today morning it show blank UIViewController no UI element vision please see in screen shot and very strange thing is that when i run my app all ui element visible in my device. I google but dont find any solution please help me out. Thank you in advance.
It looks to me like you are using size class and you went into a particular size class and added these views. Now you are back in Any size class, so the views are not there (that is why they are greyed out in the document outline at the left). They are available only for that particular size class. If you switch back to it again, whatever it was, you will see them again. Basically, you have created conditional views - the condition being that they are present only when that particular size class situation is the case.
In other words, if you want your layout to apply in the general case, you want to start by creating and editing it under Any size classes. Only then do you switch to a particular size class and modify the layout for that particular size class.
when i run my app all ui element visible in my device
Yes, because on your device the particular size class situation matches the size class you were editing when you added those views. So there they are. That seems to me to prove my guess is right.
I have the same issue while copy a ViewController to another storyboard.
Fixed by following steps:
1: Select the viewController
2: Click on 5th Tab
3: Set the simulated size to Fixed.
Select install:
Since all components [like label,textfield,buttons] are in disable mode, one select Installed check mark its will be enable again adjust constrain accordingly.
The size must be the same, in all xcode storyboard
In my case, it was due to me setting alpha to 0.0 and forgetting it.