How to select dropdown while scripting in appium - selenium

I am using Selenium Webdriver with Java and Appium to automate a mobile application, I have 1 field where I need to select a value its not typically a drop down. Manually when we select, we need to click on the element and scroll and select a value. I tried using,
driver.scrollToExact("8").click();
but this is not working.
Can you please help me on this.

on my understandings of questions
1) if you are in native app then use xpath,
2) if you are in web view try using SELECT method.

Related

I cannot Select an Element with the AndroidFindBy

I am fairly new to Appium and i am currently working on UI testing of an application. I want to click an element but it is not visible until you scroll down the page.
I have tried using the command below but it does not work for me
driver.findElement(By.xpath("new UiScrollable(new UiSelector().scrollable(true).instance(0)).scrollIntoView(new UiSelector().textContains("WebView").instance(0))")).click();
You need to replace "By.xpath" with "MobileBy.AndroidUIAutomator".
See Appium's documentation.

Unable to find xpath using Appium desktop

Use case
I need to click on ANSWER button as shown in screen below
What I Tried ?
I used Appium desktop to inspect element , but this Answer button does not seems to be effectively identified by it.
Having little experience in creating XPATH, I tried with diffrent combinations of XPATH
//android.widget.FrameLayout[contains(#text,'ANSWER')]")
//android.widget.ScrollView[contains(#text,'ANSWER')]")
//android.widget.Button[#resource-id='android:id/action0']
android:id/action0
xpath=//*[#text='ANSWER']
But none of them are working!!
Is there anyway of doing it ?

Unable to select drop down button for python selenium

How would I select this button
and click on it?
I have tried several methods and none of them have clicked it.
try with css selector and javaScript executor for select multi-class element and click it
driver.execute_script("document.querySelector('button.btn-select.nowrap-line')[0].click()")
Have you tried the class_name selector?
element = driver.find_element_by_class_name("btn-select nowrap-line")
I know you said you've tried several methods, maybe list the different ways and I can probably try to see why it's failing

WebDriverIO + Mocha + Unable to click on Toggle element

I am trying to automate a chat application build on React using WebdriverIO and Mocha as the test framework.
I am facing an issue while clicking on a toggle display element. I tried browser.click(<XPathSelector>) command at various stages, but was not able to achieve it.
There are no id or name attributes associated with the element.
Please let me know if anyone is aware of how I can accomplish this!
Try with
browser.click('Xpathselector'); or you can use a class from element like
browser.click('class'); example browser.click('.delete-class');

Unable to click button in mobile web in appium

After exhaustively searching for this over various forums, I still don't have an answer.
Here are complete details
I'm identifying the element through classname which points to multiple(4) buttons. I'm iterating through buttons and then search for text and when there is a match i click it.
This works fine with selenium webdriver and browsers such as firefox,chrome
Now I'm doing the same thing with appium.
Out of 4 buttons which are identified through classname, the script clicks 2 buttons successfully but for two buttons click happens(i can see the button being clicked) but new page which should be loaded is not loaded. The buttons for which click is not happening are in a footer class and other two are in div class.
Things i have already tried
Actions builder - click(), clickandhold()
Javascript executor
I'm currently trying with touch options, tap and by switching to native view but haven't found any success.
If any has encountered the same, a solution will be appreciated.
I want to avoid xPath because that might change in the page I'm working on, and I want to stress that the script is able to find the button, but is not able to click it properly.
You can filter your locator by using class name and index. Like this:
driver.findElementsByXPath("//*[#class='android.widget.ImageView' and #index='0']");
This xpath won't get change on other devices too.
Could you see: Unable to find an element in Browser of the Android emulator using Appium and C# ?
In case of testing web apps in browser the elements should be located as usual elements on the web page ( not as some classes like android.widget.EditText and android.widget.Button).
Upadting appium java client to 1.5.0 (from 1.3.0) solved the issue. Need to check why!