Skip to content
This repository has been archived by the owner on Jan 13, 2025. It is now read-only.

Commit

Permalink
first gradle start for servers, appium and selendroid
Browse files Browse the repository at this point in the history
  • Loading branch information
Georg Mueksch committed Aug 29, 2014
1 parent 0730811 commit 477f9aa
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 128 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.idea/
.gradle/
geb-mobile-extension.iml
build/
src/test/resources/testapk/resigned-selendroid-test-app-0.9.0.apk
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@

## Geb Mobile Extension for appium ( UIAutomator ) and selendroid ( InstrumentationFramework ) ##

# for easy dev: put break-point on desired method,
# open evalute window: (CTRL-U) , run
# AppiumPageSourceConverter.writeActivityContent(driver)
* for easy dev: put break-point on desired method,
* open evalute window: (CTRL-U) , run
* AppiumPageSourceConverter.writeActivityContent(driver)


# Info zu AppiumDriver
Expand Down
93 changes: 74 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apply plugin: 'groovy'
apply plugin: 'maven'
apply plugin: 'idea'

group = 'mueke'
group = 'dr.legacy'
version = '0.1-SNAPSHOT'

ext.gebVersion = '0.9.1'
Expand All @@ -12,7 +12,12 @@ ext.groovyVersion = '2.3.4'
ext.selendroidVersion = '0.10.0'

repositories {
mavenCentral()
mavenCentral()
}

configurations {
selendroid
iosdriver
}

dependencies {
Expand Down Expand Up @@ -48,44 +53,94 @@ dependencies {
compile "io.selendroid:selendroid-standalone:$selendroidVersion"
compile "io.selendroid:selendroid-client:$selendroidVersion"
compile "org.uiautomation:ios-client:0.6+"
compile('io.appium:java-client:1.6.1'){
// exclude module: "selenium-java"
compile('io.appium:java-client:1.6.1') {
//exclude module: "selenium-java"
}

selendroid "io.selendroid:selendroid-standalone:${selendroidVersion}"

iosdriver "org.uiautomation:ios-server:0.6+"

}

task startSelendroid << {
"java -jar ${projectDir}"
def startServer = { server, command ->
println "Starting $server with $command"
ProcessBuilder builder = new ProcessBuilder(command.split(' '))
builder.redirectErrorStream(true)
builder.directory(buildDir)
Process process = builder.start()
ext[server] = process
println "$server started : $process"
Thread.start("logging-$server") {
FileOutputStream fout = new FileOutputStream(new File(buildDir, "${server}.log"))
int bb
while ((bb = process.getInputStream().read()) > 0) {
fout.write(bb)
}
}
}

task startAppium << {
"appium --command-timeout 90000 &".execute()
def stopServer = { server ->
if (ext.has(server)) {
def process = ext.get(server)
println "send CTRL-C to server"
process.getOutputStream().write(3)
process.getOutputStream().flush()
process.destroy()
} else {
println "No Server $server found in process list"
}
}

task startSelendroid << {
startServer( "SELENDROID" , "java -cp ${configurations.selendroid.files.toList().join(":")} io.selendroid.SelendroidLauncher -port 4444 -aut ${projectDir}/src/test/resources/testapk/selendroid-test-app-0.9.0.apk")
}
task stopSelendroid << {
stopServer( "SELENDROID" )
}
task startAppium << {
//startServer("APPIUM", "appium --command-timeout 90000")
}
task stopAppium << {
stopServer("APPIUM")
}
task startIosdriver << {
"java -jar ios-driver".execute()
startServer( "IOSDRIVER", "java -cp ${configurations.iosdriver.files.toList().join(":")} org.uiautomation.ios.IOSServer" )
}
task stopIosdriver << {
stopServer("IOSDRIVER")
}

task stopServers << {
["SELENDROID","APPIUM","IOSDRIVER"].each{
if( ext.has(it) ) stopServer(it)
}
}

task runSelendroidTests(type:Test,dependsOn:[startSelendroid]) {
task runSelendroidTests(type: Test, dependsOn: [startSelendroid]) {
systemProperty "appUT_absolutePath", "${projectDir}/src/test/resources/testapk/selendroid-test-app-0.9.0.apk"
systemProperty "appUT.package","io.selendroid.testapp"
systemProperty "appUT.version","0.10.0"
systemProperty "appUT_cap_Emulator","false"
systemProperty "framework","selendroid"
include ''

systemProperty "appUT.package", "io.selendroid.testapp"
systemProperty "appUT.version", "0.10.0"
systemProperty "appUT_cap_Emulator", "false"
systemProperty "framework", "selendroid"
include '**/GebMobileAutomationTestWithPagesSpec.*'
}

task runAppiumTests( type: Test, dependsOn:[startAppium]){
systemProperty "appUT.package","io.selendroid.testapp"
task runAppiumTests(type: Test) {
systemProperty "appUT.package", "io.selendroid.testapp"
systemProperty "appium_app", "${projectDir}/src/test/resources/testapk/selendroid-test-app-0.9.0.apk"
//To run the test on a specific device
//System.setProperty("appium_udid","192.168.56.10:5555")
//System.setProperty("appium_automationName","selendroid")

//Use Appium
systemProperty "framework","appium"
systemProperty "framework", "appium"
include '**/GebMobileAutomationTestWithPagesSpec.*'
}

tasks.withType(Test){ task->
stopServers.mustRunAfter(task)
ignoreFailures = true
}


Expand Down
39 changes: 39 additions & 0 deletions config/iosdriver_logging.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
.level = FINEST
handlers = java.util.logging.ConsoleHandler,java.util.logging.FileHandler
org.uiautomation.ios.level = FINEST

org.uiautomation.ios.IOSServer.level = FINEST

org.uiautomation.ios.mobileSafari.level = WARNING
org.uiautomation.ios.wkrdp.internal.DefaultMessageHandler.level = WARNING
org.uiautomation.ios.mobileSafari.WebInspector.level = WARNING
org.uiautomation.ios.wkrdp.ResponseFinderList.level = WARNING

#DOMContext
org.uiautomation.ios.wkrdp.DOMContext.level = WARNING

org.uiautomation.ios.wkrdp.WebInspector.level = WARNING
org.uiautomation.ios.wkrdp.events.level = WARNING
org.uiautomation.ios.wkrdp.internal.AlertDetector.level = WARNING
org.uiautomation.ios.servlet.IOSServlet.level = WARNING
org.uiautomation.ios.servlet.level = WARNING
org.uiautomation.ios.application.LanguageDictionary.level = OFF

# webkit protocol
org.uiautomation.ios.wkrdp.message.level = FINEST
org.uiautomation.ios.command.web.level = FINEST
org.uiautomation.ios.mobileSafari.remoteWebkitProtocol.RemoteIOSDriver.level= FINEST

#instruments output.
org.uiautomation.ios.servlet.InstrumentsLogServlet.level = FINEST
org.uiautomation.ios.utils.level = FINEST

# Console Logging
#java.util.logging.SimpleFormatter.format="%4$s: %5$s [%1$tc]%n"
java.util.logging.ConsoleHandler.level = ALL
java.util.logging.ConsoleHandler.formatter = org.uiautomation.ios.LogFormatter

# File Logging
java.util.logging.FileHandler.level = ALL
java.util.logging.FileHandler.pattern = ios-driver.log
java.util.logging.FileHandler.formatter = org.uiautomation.ios.LogFormatter
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,9 @@ class GebMobileDriverFactory {
log.error("eXC: $e.message", e)
if( e.message =~ /Android devices must be of API level 17 or higher/ ){
capa.setCapability("automationName","selendroid")
driver = new SelendroidDriver(getURL("http://localhost:4723/wd/hub"), capa)
try {
driver = new SelendroidDriver(getURL("http://localhost:4723/wd/hub"), capa)
}catch(ex){ log.error("Error:",ex)}
}
}
if (!driver) throw new RuntimeException("Appiumdriver could not be started")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package geb.mobile.android.instrumention.specification.selendroid
package geb.mobile.android.instrumention.specification

import geb.mobile.GebMobileBaseSpec
import geb.mobile.android.instrumention.activities.HomeScreenActivity
import geb.mobile.android.instrumention.activities.WebViewActivity
import spock.lang.Stepwise
Expand All @@ -8,7 +9,7 @@ import spock.lang.Stepwise
* Created by gmueksch on 23.06.14.
*/
@Stepwise
class GebMobileAutomationTestWithPagesSpec extends GebMobileAutomationTestBase {
class GebMobileAutomationTestWithPagesSpec extends GebMobileBaseSpec {

def "open test-app and enter text "() {
given:
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

13 changes: 6 additions & 7 deletions src/test/resources/GebConfig.groovy
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
/*
Minimum GebConfig
*/

import geb.mobile.GebMobileNavigatorFactory
import geb.mobile.driver.GebMobileDriverFactory
import io.appium.java_client.AppiumDriver

Class.forName("io.appium.java_client.AppiumDriver")

driver = {
// System.setProperty("appUT.package","io.selendroid.testapp")
// System.setProperty("appium_app", new File(ClassLoader.getSystemResource("testapk/selendroid-test-app-0.9.0.apk").toURI()).absolutePath)
// //To run the test on a specific device
// //System.setProperty("appium_udid","192.168.56.10:5555")
// //Use Appium
// System.setProperty("framework","appium")

GebMobileDriverFactory.createMobileDriverInstance()
}

Expand Down
Binary file modified src/test/resources/testapk/selendroid-test-app-0.9.0.apk
Binary file not shown.

0 comments on commit 477f9aa

Please sign in to comment.