WebDriverIO + Mocha + Unable to click on Toggle element - selenium

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');

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.

Identifying ExtJS elements with selenium webdriver

I am having handling a drop down button in EXTJS application which i am trying to automation with selenium web driver.
clicking on the image i will get a list of elements in the form of 's
to click select from
Please help me how i can device a xpath to click this image, which i should not use "id" (as its extjs it might vary every now and then).
if there are any selector i can use for extjs please suggest. Thanks for your help.
<DIV id=ext-gen2337 class=x-form-field-wrap style="WIDTH: 0px"><INPUT id=ext-gen2023 class=" x-form-text x-form-field" style="WIDTH: 297px" readOnly size=24 value="Clients with pending exceptions" name=ext-gen2023 autocomplete="off"><IMG id=ext-gen2338 class="x-form-trigger x-form-arrow-trigger" src="https:REDACTED/com.ssc.epw.gui.EPWHome/clear.cache.gif">
Try below XPath to match required img element:
//input[#value="Clients with pending exceptions"]/following-sibling::img
So if you want to start testing ExtJS app and you don't want to use the best solution for this such as Sencha Test or Bryntum Siesta.
The best way to approach this is to write you own layer between the ExtJS components and the html dom of the site.
You can see more info in my answer here https://stackoverflow.com/a/41718879/1768843
But what you need to do is to use the Ext.Component.Query, with Selenium you can execute the javascript code on the site. So you execute the ext query and you pass there the Ext selector - for example button[text=something] or panel[name=mainPanel] simply any ExtJS component selector. This will return you the ExtJS object and with it you can simply call .getDom() or .getId() which will return you the actual dom or id used in the HTML. Next you can simply use the webdriver functions for clicking (or something) on the HTML elements in the site.
^^ You need to do this because the ExtJS framework can generate the HTML every-time little bit differently. For example you add new container or you upgrade your ExtJS version and the HTML is changed and your test can stop working. But if you call the Ext components as log as the Ext source code is still the same your tests will be always working.
But doing this is quite a hassle and lot of work. It's much better to use prepared solutions such as Sencha Test where everything is already prepare for testing ExtJS apps.
I would do something like this:
driver.findElement(By.xpath("//div[contains(#class, 'x-form-field-wrap')]//img"));
or
driver.findElement(By.xpath("//img[contains(#src, 'https://REDACTED/com.ssc.epw.gui.EPWHome/clear.cache.gif')]"));

Not able to click on ionic specific tags in hybrid app using appium

I am trying to automate a hybrid app build in ionic2/cordova and typescript
HTML page somewhat looks like
<ion-input _ng_somename class="header-signin-part">
<input class="header" placeholder="heading" color="abc">
When I am trying to identify element using Xpath I am not able to
//ion-input//input[#class='header']
//input[#placeholder='heading']
I tried various other combinations but in vain. Can anybody tell me why am I struggling to identify elements. is it something in ionic which is stopping the element identification(ionic specific tags for not identifiable in webview)
Steps whih I am doing
Launching the app using appium
Switching the context with driver.Context="WebView_1";(C# way of switching context)
Opening the safari browser and navigating to "localhost:27753" (Note: I have already started the webkit debug proxy on same port)
Identifying the elements
Also, app gets close everytime after some time without I doing anything. It doesn't hold on to webview
I am using only appium(not protractor) for automation
there are multiple ways you can locate this element:
<ion-content class="scroll-content ionic-scroll has-header">
You can try:
xpath: //ion-content[#class='scroll-content ionic-scroll has-header'] (please bear in mind, it looks like there are two space chars between ionic-scroll and has-header)
xpath: //ion-view[#view-title='Home']/ion-content
css selector: ion-content[class='scroll-content ionic-scroll has-header']
css selector: ion-view[view-title='Home'][class='pane']>ion-content

How to select dropdown while scripting in appium

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.

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!