Context switching issue in appium mobile automation - mobile

Hi I tried switching from native to hybrid pages in mobile automation . it throws an error chrome driver is already in use. How to fix it in mobile automation.

If you need to automate android app using java, you can switch between contexts using the below method.
public final String WEBVIEW = "WEBVIEW_com.maxsoft.testextractor";
public final String NATIVE_APP = "NATIVE_APP";
public void switchContextTo(String context){
if (context.toLowerCase().equals(WEBVIEW.toLowerCase())) {
androidDriver.context(WEBVIEW); // set context to WEBVIEW_1
} else {
androidDriver.context(NATIVE_APP); // set context to NATIVE_APP
}
}

Related

Codename One Full Screen Google Ad not loading

I have an Android app that I want to use with full screen Google ads.
I have got the small ad running, but the full screen ad does show any content.
The information I found on the internet is a little conflicting.
This link here https://github.com/chen-fishbein/admobfullscreen-codenameone advises to add several build hints to the project, but then it refuses to build.
The other one here https://github.com/shannah/admobfullscreen-codenameone does not mention any build hints, but then the ads won't load.
The answer here unable to build codename one app after adding admobfullscreen lib tells to ignore the includeGplayServices hint.
I have build the project with the sample code, but to no avail.
What would be the correct approach?
Edit : code added
String idTest = "ca-app-pub-3940256099942544/6300978111";
String idReal = "ca-app-pub-3524209908223138~0000000000";
admobTestId = new AdMobManager(idTest);
admobRealId = new AdMobManager(idReal);
f.addComponent(new Button(new Command("admob test load and show"){
public void actionPerformed(ActionEvent evt) {
admobTestId.loadAndShow();
}
}));
f.addComponent(new Button(new Command(" admob real load & show"){
public void actionPerformed(ActionEvent evt) {
admobRealId.loadAndShow();
}
}));

How to test single registration page using selenium web driver and provide test report to development team?

I know basic selenium web driver and also written code using Page Object Model in TestNG frame work for one small application registration and login page.
Bu i don't know, how can provide test report to development team and what are the check points for automation testing please help me.
Example:
Assume my application have two pages like Registration and signin page
My code:
public class Sample {
Authentication_Locators authenticate;
WebDriver d = null;
#BeforeTest
public void beforeTest() throws Exception {
d = InitDriver.wbDriver("chrome", testData.getProperty("testUrl"));
authenticate = PageFactory.initElements(d,
Authentication_Locators.class);
}
#Test (priority = 0)
public void signIn() throws Exception {
Thread.sleep(1000);
authenticate.userName.sendKeys("user1");
authenticate.password.sendKeys("password1");
authenticate.signin.Click();
}
}
TesgNG creates HTML report of the execution which is located in the current working directory under results folder with name emailable_report. Also for more accurate reports you can also use Soft and hard asserts.
Hope this helps.

(Android Studio) Connecting an app to Google Endpoints Module

I'm having trouble following the second step here.
I really don't understand how this sample does anything other than return a simple toast message. How does it utilize the API to display that message?
class EndpointsAsyncTask extends AsyncTask<Pair<Context, String>, Void, String> {
private static MyApi myApiService = null;
private Context context;
#Override
protected String doInBackground(Pair<Context, String>... params) {
if(myApiService == null) { // Only do this once
MyApi.Builder builder = new MyApi.Builder(AndroidHttp.newCompatibleTransport(),
new AndroidJsonFactory(), null)
// options for running against local devappserver
// - 10.0.2.2 is localhost's IP address in Android emulator
// - turn off compression when running against local devappserver
.setRootUrl("http://10.0.2.2:8080/_ah/api/")
.setGoogleClientRequestInitializer(new GoogleClientRequestInitializer() {
#Override
public void initialize(AbstractGoogleClientRequest<?> abstractGoogleClientRequest) throws IOException {
abstractGoogleClientRequest.setDisableGZipContent(true);
}
});
// end options for devappserver
myApiService = builder.build();
}
context = params[0].first;
String name = params[0].second;
try {
return myApiService.sayHi(name).execute().getData();
} catch (IOException e) {
return e.getMessage();
}
}
#Override
protected void onPostExecute(String result) {
Toast.makeText(context, result, Toast.LENGTH_LONG).show();
}
I'm afraid my this sample is too complex for my limited knowledge. How exactly do I "talk" to the Google Endpoints Module when running an app? Specifically, What is EndpointsAsyncTask();?
Are there any resources listing all the methods available to me? Is there a simpler example of an app communicating with a Google Cloud Endpoint?
The service methods available to you are defined by the backend source in section 1.
In the example you posted, this line: myApiService.sayHi(name).execute()
is an actual invocation call to the backend that you defined by annotating #ApiMethod("sayHi") on the method in the MyEndpoint.java class of your backend module.
The reason your Android app defines an EndpointsAsyncTask is because slow operations such as calls that hit the network need to happen off of the UI thread to avoid locking the UI. The demo simply puts the returned value into a Toast but you could modify onPostExecute() to do whatever you'd like with the result.
For more info on Google Endpoints check out:
https://cloud.google.com/appengine/docs/java/endpoints/
And for info about using an Android AsyncTask look here:
http://developer.android.com/reference/android/os/AsyncTask.html

Tabris, Eclipse RAP: Is there a public API to get to know which client has requested the page?

I am writing a RAP application using Eclipse RAP. The client may be any brower, an iPad or an android tablet (using Tabris). Is there any chance to find out which client has sent a request?
The background for my question is: Tabris does not support SashForms until now. For this reason, I want to render a SashFrom in case I am serving a web client but don't want to create a SashForm if serving the android client. I could do something like this:
public static boolean isAndroid() {
return getUserAgent().contains(Constants.ID_ANDROID);
}
private static String getUserAgent() {
return RWT.getRequest().getHeader(Constants.USER_AGENT);
}
public static boolean isIos() {
return getUserAgent().contains(Constants.ID_IOS);
}
public static boolean isWeb() {
return !isAndroid() && !isIos();
}
But I'd like to avoid this approach, because it uses internal API and since I am using standalone RAP I need to add a the servlet-api.jar to WEB-INF/lib folder to get this running, which is also not very nice.
Thanks in advance for your help and information,
Tobias.
I think this can help: https://github.com/eclipsesource/tabris/blob/master/com.eclipsesource.tabris/src/com/eclipsesource/tabris/ClientDevice.java
One alternative approach instead of using ClientDevice is to use RWT.getClient().
if( RWT.getClient() instanceof WebClient ) {
....
}
This is sometimes useful because ClientDevice can be null if the web client accesses the application. It's a client service that is only valid for the mobile client atm.

Silverlight communication with XML RPC console server

I want to comunicate with Console XML RPC server from my silvelight application. Is it possibile?
Steps:
1. Start the Console XML RPC server
Code for Console XML RPC server is this:
using System;
using System.Collections;
using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Http;
using CookComputing.XmlRpc;
public class StateNameServer : MarshalByRefObject, IStateName
{
public string GetStateName(int stateNumber)
{
return "whatever";
}
}
class _
{
static void Main(string[] args)
{
IDictionary props = new Hashtable();
props["name"] = "MyHttpChannel";
props["port"] = 5678;
HttpChannel channel = new HttpChannel(props,null,new XmlRpcServerFormatterSinkProvider());
ChannelServices.RegisterChannel(channel,false);
RemotingConfiguration.RegisterWellKnownServiceType(
typeof(StateNameServer),"statename.rem",WellKnownObjectMode.Singleton);
Console.WriteLine("Press <ENTER> to shutdown");
Console.ReadLine();
}
}
Run Silverlight application
I used the code from http://code.google.com/p/xmlrpc-silverlight/
I created new Silverlight application to which I have attached the code from that link. When I start web site (in localhost with port 1139) which executes my SL app happens SecurityException.
void ResponseResponse(IAsyncResult result)
{
XmlRpcHelperRequestState state = result.AsyncState as XmlRpcHelperRequestState;
try
{
state.Response = (HttpWebResponse)state.Request.EndGetResponse(result);
...
}
catch (Exception e)
{
// comes here with SecurityException
}
finally
{
...
}
}
I am using VS2008 Professional,XP Professional, .net 3.5, Silverlight3. I will gladly provide any additional information (or code) which is needed.
I suspect that this is a case of a missing clientaccesspolicy.xml file.
Since your silverlight app will have been launched from another authority it will attempt to access this file the http://localhost:5678/. Since you little test doesn't support that file Silverlight blocks this cross "domain" activity.

Resources