what are the prerequisites to perform mobile testing on sauce labs? - appium

i am new to Appium. I want to perform mobile testing on android and i OS app using appium tool on sauce labs.
I want to know what are the pre-requisites, and how to write the scripts(in java) and how exactly the flow goes.
can anybody help me out??
Thanks a lot in advance.. :-)
package com.saucelabs;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestName;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import java.net.URL;
import static junit.framework.Assert.assertEquals;
/**
* Simple {#link RemoteWebDriver} test that demonstrates how to run your Selenium tests with Sauce OnDemand.
* *
* #author Ross Rowe
*/
public class DemoScript {
private WebDriver driver;
#Before
public void setUp() throws Exception {
DesiredCapabilities caps = DesiredCapabilities.android();
caps.setCapability("browserName", "");
caps.setCapability("platformVersion", "4.4");
caps.setCapability("appiumVersion", "");
caps.setCapability("platformName", "Android");
caps.setCapability("deviceName", "Android Emulator");
caps.setCapability("device-orientation", "portrait");
/* DesiredCapabilities capabillities = DesiredCapabilities.iphone();
capabillities.setCapability("version", "5.0");
capabillities.setCapability("platform", Platform.MAC);*/
this.driver = new RemoteWebDriver(
new URL("http://**********************"),caps);
}
#Test
public void basic() throws Exception {
driver.get("http://www.amazon.com/");
assertEquals("Amazon.com: Online Shopping for Electronics, Apparel, Computers, Books, DVDs & more", driver.getTitle());
}
#After
public void tearDown() throws Exception {
driver.quit();
}
}
i am new to Appium. I want to perform mobile testing on android and i OS app using appium tool on sauce labs.
I want to know what are the pre-requisites, and how to write the scripts(in java) and how exactly the flow goes.
can anybody help me out??
Thanks a lot in advance.. :-)
Are there any changes required in the code?
Is appium server should be started before running the script?

Related

Flutter testing find.pageBack() on IOS doesn't work

I use flutter_driver and gherkin for test my app.
I want to use action to page back (find.pageBack()) but the Flutter Driver doesn't found the button on IOS emulator. On Android, it's ok.
I don't have any error just a timeout : TimeoutException after 0:00:10.000000: Future not completed
import 'package:flutter_driver/flutter_driver.dart';
import 'package:flutter_gherkin/flutter_gherkin.dart';
import 'package:gherkin/gherkin.dart';
class NavValidation extends ThenWithWorld<FlutterWorld> {
#override
Future<void> executeStep() async {
await FlutterDriverUtils.getText(world.driver, find.text('sagittarius / yesterday'));
await FlutterDriverUtils.tap(world.driver, find.pageBack());
}
RegExp get pattern => RegExp(r"user should land on result screen");
}

Micronoaut ServerStartupEvent callback not called in startup?

Just started to experiment with MN M3. Created a minimal Groovy service with the following code:
package test2
import groovy.transform.CompileStatic
import io.micronaut.context.event.ApplicationEventListener
import io.micronaut.runtime.Micronaut
import io.micronaut.runtime.server.event.ServerStartupEvent
#Singleton
#CompileStatic
class Application implements ApplicationEventListener<ServerStartupEvent> {
static void main(String[] args) {
println "Start"
Micronaut.run(Application.class)
}
#Override
void onApplicationEvent(ServerStartupEvent event) {
println "Boo!"
}
}
I get the "Start" but the startup event callback is never called:
Start
10:35:54.066 [main] INFO io.micronaut.runtime.Micronaut - Startup
completed in 897ms. Server Running: http://localhost:32034
I think this is the appropriate way to deal with initialization in MN?
Turns out Groovy has its own #Singleton annotation which was used by default. You need to import:
import javax.inject.Singleton
Might be a good idea to emphasize this somewhere in the docs.

Trying to trigger JMX Mbean functions from command line

My application is running on Wildfly-8.0.1. Currently, I am able to trigger MBean methods through JConsole using service:jmx:http-remoting-jmx://localhost:9990.
I want to write some script to trigger those commands but I didn't find a supporting tool to accomplish that.
I tried below tools, but it seems like they are not supporting http-remoting-jmx protocol or may be I am not using in right way
1. JMXTerm
2. Cmdline_JMXClient
3. JManage
4. CJMX
Here is the error from JMXTerm
$>open service:jmx:http-remoting-jmx://localhost:9990
RuntimeIOException: Runtime IO exception: Unsupported protocol: http-remoting-j
mx
any help would greatly be appreciated.
Create custom jar file using below class.
import javax.management.MBeanServerConnection;
import javax.management.ObjectName;
import javax.management.remote.JMXConnector;
import javax.management.remote.JMXConnectorFactory;
import javax.management.remote.JMXServiceURL;
public class JMXCli {
//private static List<String> operations;
private static final String SERVICE_URL = "service:jmx:http-remoting-jmx://";
public static void main(String[] args) throws Exception {
JMXServiceURL url = new JMXServiceURL(SERVICE_URL + args[0]);
JMXConnector connector = JMXConnectorFactory.connect(url);
MBeanServerConnection connection = connector.getMBeanServerConnection();
ObjectName objectName = new ObjectName("com.xyz.com:name=<<Your MBean class name>>");
System.out.println(connection.invoke(objectName, args[1], null, null));
}
}

Can not explore database created by an embedded neo4j

I encounter a strange problem.
I created an database using embedded neo4j whose path is "/Users/bondwong/Documents/workspace/pamela/target/data/pamela.db".
Here is the Spring configuration:
<bean id="graphDbBuilder" factory-bean="graphDbFactory"
factory-method="newEmbeddedDatabaseBuilder">
<constructor-arg value="target/data/pamela.db" />
</bean>
Then I changed this line of neo4j-server.properties:
org.neo4j.server.database.location=/Users/bondwong/Documents/workspace/pamela/target/data/pamela.db
After that, I used curl to test my system, which showed all is good. Here is the result of getting a node whose id is 9:
However, when I fired up the server, and use the browser to see the data, nothing shows up:
Here is the location, it is the same as the one in the Spring XML configuration file:
Here is the :sysinfo result:
Here is the jUnit test and its result, showing that it actually insert the data:
package repositoryTest;
import static org.junit.Assert.*;
import java.util.HashMap;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
import com.bond.pamela.domain.Diary;
import com.bond.pamela.domain.factory.DiaryFactory;
import com.bond.pamela.persistence.DirayRepository;
#RunWith(SpringJUnit4ClassRunner.class)
#ContextConfiguration({ "/applicationContext.xml" })
public class DiaryRepositoryTest {
#Autowired
DirayRepository repository;
#Test
#Transactional
public void testSaveDiary() {
Diary diary = (Diary) DiaryFactory.getInstance().create(
new HashMap<String, Object>());
repository.save(diary);
Diary retrivedDiary = repository.findOne(diary.getGraphId());
assertEquals(diary, retrivedDiary);
}
}
I think it should work, someone knows what is wrong? and how to fix it. Thx!
You can write your java code as server extension
or use WrappingBootstrapper for the time being.
Or rather use ServerControls from Neo4j-Harness for testing
When creating the data, are you sure you committed the transaction correctly?
Transaction tx = db.beginTx();
// create data
tx.success();
tx.close();
or better
try (Transaction tx = db.beginTx()) {
// create data
tx.success();
}

JMockit Mocking java.net.URL causes test not run

I'm using the newest versions of junit and jmockit and Oracle JDK 7 in Eclipse. When I try to mock java.net.URL my test won't run.
I have in my code something like:
URL url = new URL("String representing the url.");
So I figured in my test I could mock this like so:
#Mocked private URL _url;
Since this works for pretty much everything else, I know URL is final but I thought that was okay with JMockit.
When I run a test class with the above mock in eclipse the result is a grey line(as opposed to green or red.) So I'm assuming some kind of initialization problem. The rest of the test or code doesn't seem to matter, no matter what I put that #Mocked line in, this happens.
A workaround would be great, an explanation of what is actually causing this would be even better. Any help is definitely appreciated! Thanks!
Quick example. This actually gives an exception, but I think it is basically doing the same thing I have seen:
package demo;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
public class Connecting {
public boolean connectionattempt() throws IOException {
URL url = new URL("http://nowhere/");
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
if (connection != null) {
return true;
}
else {
return false;
}
}
}
And this test:
package demo;
import static org.junit.Assert.assertEquals;
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import org.junit.Test;
import mockit.Expectations;
import mockit.Mocked;
import mockit.Tested;
public class TestConnecting {
#Mocked URL _url;
#Mocked HttpURLConnection _connection;
#Tested Connecting _sut;
#Test
public void testConnect() throws IOException {
new Expectations() { {
_url.openConnection(); result = _connection;
} };
assertEquals(true, _sut.connectionattempt());
}
}
and the stack trace:
java.lang.NoClassDefFoundError: org/eclipse/jdt/internal/junit/runner/TestReferenceFailure
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestListener.testFailure(JUnit4TestListener.java:91)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestListener.testFailure(JUnit4TestListener.java:69)
at org.junit.runner.notification.RunNotifier$4.notifyListener(RunNotifier.java:139)
at org.junit.runner.notification.RunNotifier$SafeNotifier.run(RunNotifier.java:61)
at org.junit.runner.notification.RunNotifier.fireTestFailures(RunNotifier.java:134)
at org.junit.runner.notification.RunNotifier.fireTestFailure(RunNotifier.java:128)
at org.junit.internal.runners.model.EachTestNotifier.addFailure(EachTestNotifier.java:23)
at org.junit.runners.ParentRunner.run(ParentRunner.java:315)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
I executed the test on Eclipse Kepler SR2, IntelliJ IDEA 13.1, and Netbeans 8.0.1, using JMockit 1.13, JUnit 4.11, and Oracle JDK 1.7.0_67.
The test passes in every case, it's all green! So, I don't know what could possibly be the problem in your environment. Are you sure the "newest version" of JMockit (1.13 at this time) was the one actually used?

Resources