Appium - find element by xpath not working - appium

Error LogsTrying to click on an element XPath not working. I have used several other XPath in my application. All other working expect this!
driver.find_element_by_xpath("/hierarchy/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/android.widget.LinearLayout/android.widget.FrameLayout/androidx.drawerlayout.widget.DrawerLayout/android.view.ViewGroup/android.widget.RelativeLayout/androidx.viewpager.widget.ViewPager/android.view.ViewGroup/android.widget.FrameLayout/android.widget.LinearLayout/android.view.ViewGroup/android.view.ViewGroup/android.widget.LinearLayout/android.widget.LinearLayout/android.widget.LinearLayout/androidx.recyclerview.widget.RecyclerView/android.widget.LinearLayout2/android.view.ViewGroup/androidx.recyclerview.widget.RecyclerView/android.widget.RelativeLayout2").click()

Related

Capybara, Selenium, Jupyter Notebook: filling code cell

I want to use Capybara to input text into a Jupyter Notebook cell. Clicking the element and using 'send_keys' does not work, although the cursor ends up in the right location: find(".input").click.send_keys("hello")
Is there a way to simulate pressing keys without selecting an element? find("body").send_keys("hello") also does not produce any text
Edit: I found out that the Jupyter Notebook uses CodeMirror. CodeMirror uses a hidden <textarea> field somehow, so that would explain why Selenium refused to find the input.
My current workaround is to find the first CodeMirror editor and use the setValue function on it: execute_script("var editor = $('.CodeMirror')[0].CodeMirror; editor.setValue('this is the input')")
I avoided the workaround by using Selenium's action builder. Find the desired element and get its native selenium representation:
el_native = first('.input').native
Then, use the action builder to click into the element and send keys:
page.driver.browser.action.click(el_native).send_keys("hello").perform

How can i remake XPath locators to UIAutomation locators?

How can i remake XPath locators to UIAutomation locators?
Example this xpath locator:
//UIAApplication[1]/UIAWindow[4]/UIAAlert[1]/UIAScrollView[1]/UIAStaticText[2]
Any ideas?
There are different ways to remake xpath value to UIautomation, methods are as follows.
[!Calculator app example]
http://i.stack.imgur.com/WQr3J.png
Before going to these points FYI class name is taken as reference for xpath.
XPath using class and text attribute :
In above image you can see that button 5 has text attribute with value = 5 which is unique. Class name is android.widget.Button which is same for all number buttons. So we can create XPath using text attribute value with class name as bellow.
xpath("//android.widget.Button[#text='5']")
XPath using class and resource-id :
Here resource-id for button 5 is com.android.calculator2:id/digit5. Trailing part (e.g digit5, digit4, digit7) of resource-id is changing for every number buttons so we can use contains function to get relative XPath of button 5 as bellow.
xpath("//android.widget.Button[contains(#resource-id,'digit5')]")
See more at: http://software-testing-tutorials-automation.blogspot.in/2015/10/ui-automator-viewer-get-android-app.html#sthash.08v6jFPe.dpuf
You can get UIAutomator from Instrument.(Xcode - Automation tool)
please find the below UIAutomator for ur code,
UIATarget.localTarget().frontMostApp().windows()[3].alerts()[0].scrollViews()[0].staticTexts()[1]
Note:
In Xpath index starts from 1.but in UIAutomator it starts from 0. Keep this in your mind.

Unable to find xpath "/html" (Capybara::ElementNotFound)

I was implementing capybara for a app flow. I have features/step_definitions/anonymous_booking_steps.rb with two steps
for just visiting the root path
expecting an element in next step for the above page
I am getting this error:-
Unable to find xpath "/html" (Capybara::ElementNotFound)

How to use Ios UI Automation xpath in appium for ios

I am using iosuiautomator for finding the xpath of element
(Note: In appium can't find the xpath). while running following error is displaying
When using iOSUIAutomation search strategy, you don't need localTarget().target.().etc. You can start from right after mainWindow(). I also noticed you put the tap action inside the quotes but is actually a function of the mobile element (and has 2 parameters) so what you'd want is:
driver.findElementByIosUIAutomation(".tableViews()[2].cells()[2]").tap(1, 250)

Understanding the meaning of the capybara syntax

I want to understand what the following Capybara syntax means -
find(:xpath, '//*[#id="application-lines"]/div[2]/ul/li[2]/a').click
I particularly don't understand the second attribute of the find method.
It would be great if someone could help me understand the syntax!
That is not something specific of Capybara, that is an XPath, is used to navigate the elements of an XML document.
In this case is looking for a node with id application-lines and inside that element retrieving the second div[2], with an ul element from which retrieves the second li and retrieves the a element inside it. All this ends up doing is a click on the a element found.
You can learn about XPaths here: XPath tutorial

Resources