Using Selenium Webdriver Selectors in Appium ios - java

A project I'm on is developing a web app at the same time as an ios app (for the same thing) and I'm hoping to be able to use existing Selenium tests, but we're having trouble with selectors. Is there a selector type or attribute name that can be used for both Selenium Webdriver and Appium ios, so that I can just set a variable to either browser or app and they run and work on both. Nobody on this project has used Appium before, so we are lacking a lot in knowledge.
I tried using IDs and found that ios doesn't work with them, changed to names and found that names have been removed from appium. If possible we'd prefer to use a selector that will be the same in the browser as it is in the app.
Thanks

You can create one object repository file which contains the locators for both WebApp and iOS app. Then you have to follow the below process
Create WebDriver and AppiumDriver instances
Use the relevant drivers for locating the elements in WebApp as well as iOS app. We can use both the drivers within a test case.
Please note that, the way WebDriver and AppiumDriver identifies the elements will be different. For example, in WebDriver if an element is identified by using ID then similarly in AppiumDriver an element can be identified by using the findElementByAccessibilityId.
Even though AppiumDriver uses the same logic which WebDriver uses, the method names will differ. Please find the link for all the methods used by AppiumDriver
Hope this helps.

How about creating multiple object repositories and loading the relevant object repository based on the underlying platform?
1. So you need to store locators of both the platforms in separate repositories
2. Create a Interface / wrapper which would load relevant repository based on the platform on which tests are going to run.

Didn't quite get the question but for Appium You have separated annotations for bot iOS and Android platform similar as for web via:
#FindBy(id="buttonOK")
private WebElement buttonPopUp;
Here is example for Android and iOS
#iOSFindBy(id = "lets_do_it")
#AndroidFindBy(id = "message_popup_dismiss_button")
#WithTimeout(unit = TimeUnit.SECONDS, time = 1)
private MobileElement buttonPopUp;
So in same pageObject you have covered both platforms.
Mobile platform can work together, but recommendation is not to mix web and mobile, but mobile platforms can play together just fine, and is recommended so can share same code functionality.

Related

Not able launch multiple edge browser/instance in Selenium? Selenium allows only single instance for edge?

Not able to launch multiple edge browser in selenium. I want to open second instance once I have done actions required in first application and cross check the same in another application without closing the first instance.
This is a known limitation of the driver for EdgeHTML-based versions of Microsoft Edge. It is not a problem with Selenium per se, but one with the driver, which is created an maintained by Microsoft. Criticism, complaints, and bug reports should be directed there. Having said that, note that the driver for Chromium-based Edge, now in beta, do not have this limitation.
This is a known issue, at the moment you can only run 1 instance of Microsoft Edge. That is a limitation of MicrosoftWebDriver. You could feedback this issue at the bottom of this site and create a pull request on github about this issue.

Possibilities on integrating existing cucumber framework with appium

I have an existing automated suite for web browser based application on cucumber framework using selenium and java. We are now planning to run the same test scripts for the mobile app of same application.
1. Is it possible to migrate or extend the existing web-based scripts to appium with limited code changes?
2. If option 1 is not possible, then will we have to right the entire scripts again using appium parameters or is it possible to use selenium parameters for identifying the elements of click, textbox etc.?
3. Any guidance or material on this enhancement/integration would be of much help.
1. Is it possible to migrate or extend the existing web-based scripts to appium with limited code changes?
The Framework structure could be retained .However i suggest you to create separate suite and test cases to handle appium.
Appium takes several parameter to start a session with a particular device and the session value is passed to the scripts , its like the driver being passed to Selenium scripts.
2. If option 1 is not possible, then will we have to right the entire scripts again using appium parameters or is it possible to use selenium parameters for identifying the elements of click, textbox etc.?
Appium is an extended version of selenium , so the command like Click element will work , However , i am not sure if the locator value will be same for Web element and App element.
You can try to locate your APP locator using Appium Desktop Appium Desktop for locating Elements and verify its values with locators from Web elements .
Any guidance or material on this enhancement/integration would be of much help.
Here is a tutorial if you want to learn Appium
Appium

Controlling Chrome Devtools with Selenium Webdriver

I am looking to access/use Chrome's devtools panel with Selenium Webdriver.
Specifically, I want to use the "WASP" chrome plugin, which is accessed through devtools. I've got my selenium set up to run with the WASP plugin included, and I can open DevTools (with sendKeys.F12), but I don't know how to actually use that panel now that it is open. Is there a way to do so?
The closest thing I've found to my problem is this link: Chrome Dev Tools API & Selenium WebDriver, but that hasn't been helpful at all to me.
Also, if it looks like this will be impossible (which it does) can anyone think of a workaround?
In Selenium 4 alpha, there is a way to interact with DevTools API using the java-client. What you are looking for specifically is the "Profiler" domain (https://chromedevtools.github.io/devtools-protocol/tot/Profiler)
Recently, I contributed the "Network" and "Performance" domains for a better user facing API in selenium java - https://github.com/SeleniumHQ/selenium/pull/7212
I believe that "Profiler" will also be implemented soon. Of course, there is a generic API for all domains in Java client that was merged a while ago, you can use it like this:
driver.getDevTools().createSession();
driver.getDevTools().send(new Command("Profiler.enable", ImmutableMap.of()));
driver.getDevTools().send(new Command("Profiler.start", ImmutableMap.of()));
//register to profiler events
driver.getDevTools().addListener(new Event("Profiler.consoleProfileStarted", ConsoleProfileStarted.class), new Consumer<Object>() {
#Override
public void accept(Object o) {
//do something
}
});
Until the Profiler domain will added to Selenium java client, you will have to supply your Mapper.

Capture user input and actions with Selenium WebDriver using Java

Is it possible to capture user input/actions with Selenium WebDriver, in the same way that you can use the Selenium IDE for recording / creating tests?
i.e. when the user enters a URL, clicks a link, fills in a text box, clicks a button etc etc.
I'd like to be able to capture these actions using the WebDriver rather than just using the Selenium IDE, as I want to integrate with other classes available in my Java application.
I attempted to offer a viable solution in Record Actions using Selenium
Hope this helps.
You can't 'record' a set of actions with Selenium WebDriver, you will need to write those steps manually.
Strictly speaking you can capture user input by using the WebDriver API in your chosen language (C#, Java, PHP, Ruby. Python, Perl or JavaScript) and it vaguely resembles using the DOM. If it suits your requirements you could use configuration files to supply some of your user input.
Navigate to a URL:
WebDriver driver = new FirefoxDriver();
driver.get('url')
Click a link/button:
WebElement element = driver.findElement(By.id("coolestWidgetEvah"));
element.click();
Enter Text in a field:
WebElement element = driver.findElement(By.id("coolestWidgetEvah"));
element.sendKeys('userinput');
For more information on the API Selenium HQ is pretty definitive:
http://seleniumhq.org/docs/03_webdriver.html#introducing-the-selenium-webdriver-api-by-example
If you're going from Selenium IDE to writing tests it'd be really useful to check out the page object pattern as I've found it makes your tests more maintainable in the long-run. This link is a good starting point because it gives an overview, and a visual representation of what you get by following the pattern:
http://blog.josephwilk.net/cucumber/page-object-pattern.html
Hope that helps.
As far as I'm aware, there isn't an easy way to do it - but recording on IDE and exporting as a java file has worked well for me (File -> Export test case as...). I usually do it to c# but have used it with java.

develop a user defined plugin for web browser

How to develop a user defined plugin for a web browser.
It should features:
It should be installed in any browsers.
It should be executed whenever the browser starts.
It should monitor the web page and access the web page that the browser displays.
It should monitor and access the web page (for example, getting a value from a text box) irrespective of the web page the browser displays. (The web page can be of any URL either google or any domain)
How to start with it? It would be helpful if there is some sample. Thanks in advance
For Firefox < 4 write an Addon, for 4 and above Jetpack will be the way to go. For Chrome write a Extension. Opera, well wait till 11.5 ships. Safari 5. IE.
Read the documentation for each browser.
Hm...
I hope you tell the user about that.
Right now it reads like you want to deploy something to a PC and monitor all browsers, well if you want to do that you'll have to put some effort into it.
I don't think 1. is possible, you will have to create multiple versions of your plugin in order to work with each browser.
There is not a single example, because as I mentioned, you are going to have to do something different. You will need to determine and target specific browsers. I would suggest starting with one and once you have it have it working move to the next browser.
Do you mean a Plugin (like Flash, PDF Reader) or and Extension?
Plugins are native programs and extensions are normally coded in JavaScript & HTML.
Depending on what you want to do, an extension is enough powerful and the better choice.
There is no browser independent way to implement plugins. For each browsers you must read the interface reference. For example the reference for chrome: http://code.google.com/chrome/extensions/getstarted.html

Categories