Scroll down appium robot framework fails - testing

I am trying to scroll down through settings section in an android the android opens the settings but fails and error message ValueError: Element locator '//android.widget.LinearLayout[#index="14"]' did not match any elements.
and I am sure of the xpath as i tried it for click element and it worked without problems
Here is the code
open application http://localhost:4723/wd/hub platformName=Android platformVersion=10 deviceName=emulator-5554 appPackage=com.android.settings appActivity=com.android.settings.Settings
scroll down //android.widget.LinearLayout[#index="14"]

Related

React Native iOS apps, when tested in Appium UI Automation Inspector tool, unable to read Text values

React Native iOS apps, when tested in Appium UI Automation Inspector tool, unable to read static Text values.
Code:
<Text accessibilityLabel={'home_welcome_text'} testID={'home_welcome_text'}>Welcome Home
Issue:
In Appium Inspector, label field show 'home_welcome_text'. Which is not correct, it should give the text value 'Welcome Home' in the label field.
Note: This issue happens only in iOS builds. Android builds are working as expected.
Your help on this is much appreciated. Thank you.

Selenium WebDriver: is it possible to test WebExtension that inject code to the current page?

I found articles about opening browser extension as a page - but my extension inject JS to the current page - and extension can not inject code to chrome* pages. My only choice is SikuliX? Also with SikuliX I can test the badge of my button. I think that with SikuliX I simulate real user behaviour - such tests about UI interactions looks like more robust for me. Also nice to test CSS correctness.
I tried to setup a hotkey for my extension:
But
driver.find_element_by_tag_name('body').send_keys(Keys.CONTROL + 'I') (Python) or driver.findElement(By.tagName("body")).sendKeys(Keys.CONTROL + "I") (Java)
do nothing, but I can press Ctrl+I and I see popup-UI opened.
UPDATE: I tried to use pyautogui for mouse clicking - but even with opened extension popup UI driver.window_handles does not include it :(
You can configure webdriver to load your extension in to the browser while launching as well. Once your extension in loaded , it can inject required code that i am assuming makes some changes to html such as adding / removing some html elements or applying some styles which can be then tested using Selenium. You can also execute javascript using selenium.
Sikuli framework is based on image recognition and then simulating user interactions on it using mouse and keyboard . Your test cases might break under these scenarios :
Change in resolution which may even result in layout changes
Change in theme of the application resulting in color changes of ui-elements
It will require focus ,etc.
Currently, I test my extension by comparing expected and actual screenshots, using Selenium web driver, pyautogui (for interactions with extension) and opencv2 (for computer vision), see more at https://www.pyimagesearch.com/2014/09/15/python-compare-two-images/

Recognizing element in an Hybrid App - Android

I am new to Android testing. I am currently trying to automate a scenario. I have attached the snapshot of the app screen:
Scenario:
I need to click on "Clock In".
A screen slides from the bottom as shown in the snapshot.
I need to select an item as shown by the arrow.
The developer is saying that it is a Hybrid app. A lot of confusion here for me as I am able to click on "Clock In", but I am not able to select "DL 380 Memory Upgrade".
Doubts:
How to find whether "DL 380 Memory Upgrade" is in Webview/Native?
If it is an element in the webview, how to locate it? I located "CLOCK IN" as below:
#AndroidFindBy(xpath = "//android.view.View[#resource-id='tab-t0-0']")
private AndroidElement clockInTabBtn;
If its an element in WebView, then its web and you won't find anything in web while searching by resource-id - its native attribute only.
I would recommend to use chrome dev tools for debugging hybrid application.
You can read official docs for setup.
Basically you need:
connect device
go to chrome://inspect/#devices in chrome browser
check phone & allow usb debugging if popup appears
check what webViews chrome spotted and click inspect for the one you need
And now you search for elements and their locators the same way you did in Selenum/Web automation
Don't forget to switch context to WebView in your appium test before you actually searching inside webView.
Good luck!
You can check available view using context and can switch to it using follows code:
Set<string> contextNames = driver.getContextHandles();
for (String contextName : contextNames)
{
System.out.println(contextNames);
//To swicth to webview
if (contextName.contains("WEBVIEW")){
driver.context(contextName);
}
}
Please refer this thread for similar issue: https://github.com/appium/appium/issues/7243

Selenium - Element not visible when the browser set to mobile responsive mode

I am testing the browser for mobile responsiveness. I changed the browser window size to iPhone 5 which is 320 x 568 using this command
driver.Manage().Window.Size = new Size(320, 568);
When I run the test, the browser opens fine according to the mentioned size without any issue. But it fails to find a hyperlink text which is displayed on the page. I get Element not visible exception when I could actually see the link text on the screen. So, could anyone help me solve this issue or have any ideas that I could try?
Any help would be highly appreciated.
Thanks.
Perhaps it's due to the time delay, that means code executes even before the link appears, So write the following code in your language
Code from Ruby Selenium-binding
wait = Selenium::WebDriver::Wait.new(timeout: 10) # seconds
wait.until { driver.find_element(id: "foo").displayed? }
driver.find_element(id: "foo").click
Try to scroll to the element.
You could use java script to do that.
In Python this can be done via
WebDriver.execute_script("arguments[0].scrollIntoView();", elem)
Some elements of the DOM of the webpage change when you test for mobile responsiveness, so selenium is unable to locate the element that you are specifically trying to target.So, you should try to debug and find the methods where the code is failing to perform the action.Then you should find the locators for those elements in "mobile responsiveness view" and trigger only those methods when you are testing for mobile.

How to automate native "Search" button in Appium Java

driver.findElementById("SearchField").sendKeys("bacon");
After sending keys the Native Keyboard opens automatically on IOS.
How can i automate Tap on native keyboard "Search"?
Appium + Java + Selenium + Eclipse
If you are using java-client 3.1.0, you can use this:
((AndroidDriver) driver).sendKeyEvent(AndroidKeyCode.ENTER);
Assuming you are automating a native mobile application. then you can easily click on the search button.
driver.findElement(By.Xpath("xpath of search icon")).click();
If you are automating web application then you need to change your context to native like below.
STEPS
Get the current context handles
Save the current context Context to Native
Change the Context to Native
Click on the search button
change the context to default
CODE
driver.getContextHandles();
String currentContext = driver.getContext();
driver.context("NATIVE_APP");
driver.findElement(By.Xpath("xpath of search icon")).click();
driver.context(currentContext);
Not sure if this would be helpful for you since it's been half a year but I did have a similar problem. If I was going to search with "Bruno Mars" in the search field, I would just have appium type in "Bruno Mars\n" and the newline would automatically trigger the search button. However, recently my devices weren't responding to the new line anymore. I winded up downgrading the google keyboard to 4.1.x and I was able to use new line method again. The problem was that the devices had auto updated to to version 5.x. So downgrading the keyboard solved the issue for me.