2014年11月26日 星期三

[python] python快速筆記2

變數轉成字串

Number = job.get_last_buildnumber()
NumberString = str(Number)

字串寫入換行

f.write('abc')
f.write('\n')
f.write('123')

output file:

abc
123


字串相加

URLString = str(ww.yahoo.com)
URLString += '/mail'
print URLString

output:
www.yahoo.com/mail




2014年11月25日 星期二

[Jenkins] Slave Invoke Ant時出現錯誤

Slave server Invoke Ant時報錯:

FATAL: Cannot find executable from the chosen Ant installation "Ant 1.8"
Build step 'Invoke Ant' marked build as failure

原因:
slave上面沒有安裝ant


解決辦法:
從master上設定安裝ant到slave上

Jenkins -> Manage Jenkins -> Configure System -> Ant



[Appium] 開啟appium server時創建log出現錯誤

開啟:

appium -a 127.0.0.1 -p 4723 --no-reset --session-override -lt 180000 --command-timeout 180000 --log /Users/jenkins/workspace/Orange/label/Mac_Mini_2014_1/junit/appium.log

出現錯誤:

uncaughtException: ENOENT, open '/Users/jenkins/workspace/Orange/label/Mac_Mini_2014_1/junit/appium.log'


原因:node沒有該資料夾讀寫的權限

解決辦法:

1.開放該位置讀寫的權限
2. $sudo chmod -R 1777 /Users/jenkins/workspace/Orange/label/Mac_Mini_2014_1/junit/

2014年11月24日 星期一

[html] html圖片檔案位置

    網頁檔的位置
    圖檔的位置
    寫法
    說明
    c:\demo
    c:\demo<img src="ex.gif">圖文均在同一目錄
    c:\demo
    c:\demo\image<img src="image/ex.gif">圖在網頁下一層目錄
    c:\demo
    c:\<img src=" ../ex.gif">圖在網頁上一層
    c:\demo
    c:\image<img src=" ../image/ex.gif">圖文在同一層但不同目錄

[Python] Python in Mac 一些快速筆記

IDE: Sublime Text 2

執行  Terminal-> $pyhton /Users/Downloads/test1.py

開啟檔案

f = open('helloworld.html','w')

message = """<html>
<head></head>
<body><p>Hello World!</p></body>
</html>"""

f.write(message)
f.close()

執行web server

$python -m SimpleHTTPServer 8080


pip

https://bootstrap.pypa.io/get-pip.py

將此檔案(get-pip.py)另存新檔下來,再用python執行



python + jenkins

http://pythonhosted.org//jenkinsapi/

[Junit] Junit中的@Test沒有依照名字順序執行

一個junit架構下的class有多個@Test
可是執行的時候test case沒有依照test function名子照順序執行而是亂跳

解決:
在class上面加上一行   @FixMethodOrder(MethodSorters.NAME_ASCENDING)

test function就會依照名字順序執行了

[Appium] Appium的元件定位方法

Appium元件的定位方法


wd.findElement(By.xpath(“xpath‘)); ,其中By有許多方式可以達成


By.xpath 絕對路徑  (Android、iOS)

主要用於完全無法定位的元件最後手段


Ex.
wd.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIAStaticText[11]"));


尋找方法:
使用Appium Inspector可以找到



By.name 名字  (iOS)
主要用於iOS RD寫app時有幫忙把元件標上名字時
Ex.
wd.findElement(By.name("topbar reload")).click();


尋找方法:
iOS在simulator中,Settings->Accessibility->Accessibility Inspector,
Appium Inspector也可以找到



By.id  resource ID  (Android)
主要用於Android RD有幫忙把元件標上名字時
Ex.
wd.findElement(By.id("com.myapp.test:id/url"));


尋找方法:
使用Android SDK中的hierarchy viewer,可使用含Android SDK的eclipse->DDMS->選擇Device->Dump hierarchy viewer


By.className 類別名稱  (Android、iOS)
用於從一個已知的節點,往下尋找沒有名子的特定類別的元件
尋找一個節點下面元件的方法:http://ffsonic.blogspot.tw/2014/11/appium.html


Ex.
Android:
wd.findElements(By.className("android.widget.TextView"));

iOS:
wd.findElement(By.className("UIASwitch")).click();



尋找方法:
Android - hierarchy viewer
iOS - Appium Inspector




ssss

2014年11月20日 星期四

[Appium] Appium server常用參數

Appium官方capabilities doc:

使用Terminal輸入 $appium 即可開啟appium server
開啟appium時可以添加參數使用,例如: $appium -a 127.0.0.1
輸入 $appium help  可觀看更多資訊


常用參數:


-a ip : 指定監聽的IP address
sample: -a 127.0.0.1


-p port : 指定監聽的port
sample: -p 4725


--no-reset: 每個session間不清除app資料。預設是false,每個session都會清除app data,加入此參數為 = true


-lt millisecond: 啟動app timeout秒數。session啟動app後,超過此時間app沒有launch會自動斷掉session,預設是60秒。
sample: -lt 180000


--command-timeout millisecond: 每個command之間的timeout秒數。超過此時間appium server沒有收到command會斷掉session。
sample: --command-timeout


--log directory: 輸出appium log到指定位置的檔案。
sample: --log /Users/Downloads/appium.log

--session-override: 強制覆寫session,預設為false。appium server一次只能接受一個session,當目前server正在執行一個session時有新的session進來,後來的session會被拒絕。使用此參數=true,當有新的session進來時會強制拋棄舊的seesion而使用新的session

2014年11月19日 星期三

[Mac] Mac執行檔案指令

執行.sh script

$cd /location/
$sh script

$cd /location/
$bash script

啟動執行檔

$cd /location/
$./script

sample:

cd /Downloads/adb/
./adb devices



[Appium] Appium跑iOS app的條件

大前提:台Mac的Xcode必須登入一個有iOS Development的帳號,不然連安裝app時都會失敗


1. 跑在simulator:
build app時必須額外加入simulator SDK

2.跑在device
必須有原始碼,開啟xcode -> Product -> Build For -> Testing
.app位置: /Users/Library/Developer/Xcode/DerivedData/workspace/Build/Products/Debug-iphones/

build app的電腦跟跑的電腦可以不一樣,只要apple id都有權限就可以

[Appium] 使用一個總設定檔管理全部script的設定

script跟appium server溝通主要有兩個重點:

1.Capabilities
2.ip

如果把這兩個變數都寫死在全部的腳本裡面,會造成想要修改參數時非常麻煩
例如:你有50個script,當想要修改ip的時候得把50個script檔案都打開來修改...

可以寫一個總設定檔,把設定寫成function在裡面,當腳本需要連線時呼叫函數回傳設定

範例:


總設定檔:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public class AllSettings {
 

 public static DesiredCapabilities Set(){
  //set all Capability
  DesiredCapabilities set = new DesiredCapabilities();
  set.setCapability("appium-version", "1.3.1");
  set.setCapability("device", "iOS Simulator");
  set.setCapability("deviceName", "iPad Air");
  set.setCapability("platformName", "iOS");
  set.setCapability("platformVersion", "8.1");
  set.setCapability("showSimulatorLog", "true");
  set.setCapability("app","/Users/blabla/blabla");
  return set;
 }

 public static String URL(){
  return "http://127.0.0.1:4725/wd/hub";
 }
}

腳本:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import AllSettings;

public class sample {
 AppiumDriver wd = null;

 @Test
 public void test() throws MalformedURLException, InterruptedException {
  wd = new AppiumDriver(new URL(AllSettings.URL()),AllSettings.Set());
  wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
  
 }
 
}


這樣對於管理全部的腳本非常方便,也不用每個腳本都去確認設定是否正確




[Appium] Appium在device上launch app時不斷閃退又重開

iOS8以上可能遇到這個問題,到device settings裡面=>Developer=>enable UI Automation


2014年11月17日 星期一

[Appium] 一台電腦同時跑多台android device

1台appium server對應一個appium session
一台電腦中可以開啟多個appium server (需使用不同的port)
開啟appium server時,給-U udid 參數即可指定要跑的device (不然會全部跑在同一台上)
UDID可用 adb devices得到


[Appium] Appium for Mac安裝

http://testerhome.com/topics/1225


2014年11月16日 星期日

[Appium] iOS點擊或滑動螢幕坐標報錯超出範圍

http://testerhome.com/topics/1589

滑動:從起始點X.Y 長按到結束點X.Y

1
2
3
4
5
6
7
8
9
10
11
12
13
public static void ScrollDown(AppiumDriver wd) throws InterruptedException {
  JavascriptExecutor js = (JavascriptExecutor) wd;
  HashMap<String, Double> flickObject = new HashMap<String, Double>();
  // set start point and end point
  flickObject.put("startX", 300.0);
  flickObject.put("startY", 800.0);
  flickObject.put("endX", 300.0);
  flickObject.put("endY", 500.0);
  flickObject.put("duration", 500.0);
  //do action
  js.executeScript("mobile: flick", flickObject);
  Thread.sleep(delay);
 }


這邊有個坑,如果你是用Appium Inspector 找iOS中的一個坐標要滑動或是點擊,像是這樣的話


要注意! Appium Inspector的坐標是Device放大過後的坐標,而上面那語法是點擊最底層的logic screen,而不是被放大過後的Device screen

以iPad retina來說是放大兩倍,所以要把抓到的坐標/2,寫在code裡面,這樣點擊的坐標才會是正確的



原理:

http://www.iosres.com/

[Android] Android key event code,模擬各種鍵盤上的按鍵

http://developer.android.com/reference/android/view/KeyEvent.html


主要常用:

Enter     66
Delete   67
Back     4


KEYCODE_0      '0' key.   7
KEYCODE_1      '1' key.   8
KEYCODE_2      '2' key.   9
KEYCODE_3      '3' key.   10
KEYCODE_4      '4' key.   11
KEYCODE_5      '5' key.   12
KEYCODE_6      '6' key.   13
KEYCODE_7      '7' key.   14
KEYCODE_8      '8' key.   15
KEYCODE_9      '9' key.   16

KEYCODE_A      'A' key.   29
KEYCODE_B      'B' key.   30
KEYCODE_C      'C' key.   31
KEYCODE_D      'D' key.   32
KEYCODE_E      'E' key.   33
KEYCODE_F      'F' key.   34
KEYCODE_G      'G' key.   35
KEYCODE_H      'H' key.   36
KEYCODE_I      'I' key.   37
KEYCODE_J      'J' key.   38
KEYCODE_K      'K' key.   39
KEYCODE_L      'L' key.   40
KEYCODE_M      'M' key.   41
KEYCODE_N      'N' key.   42
KEYCODE_O      'O' key.   43
KEYCODE_P      'P' key.   44
KEYCODE_Q      'Q' key.   45
KEYCODE_R      'R' key.   46
KEYCODE_S      'S' key.   47
KEYCODE_T      'T' key.   48
KEYCODE_U      'U' key.   49
KEYCODE_V      'V' key.   50
KEYCODE_W      'W' key.   51
KEYCODE_X      'X' key.   52
KEYCODE_Y      'Y' key.   53
KEYCODE_Z      'Z' key.   54

META_ALT_LEFT_ON   This mask is used to check whether the left ALT meta key is pressed.            16
META_ALT_MASK      This mask is a combination of META_ALT_ON, META_ALT_LEFT_ON and META_ALT_RIGHT_ON.      50
META_ALT_ON      This mask is used to check whether one of the ALT meta keys is pressed.            2
META_ALT_RIGHT_ON   This mask is used to check whether the right the ALT meta key is pressed.         32
META_CAPS_LOCK_ON   This mask is used to check whether the CAPS LOCK meta key is on.            1048576
META_CTRL_LEFT_ON   This mask is used to check whether the left CTRL meta key is pressed.            8192
META_CTRL_MASK      This mask is a combination of META_CTRL_ON, META_CTRL_LEFT_ON and META_CTRL_RIGHT_ON.      28672
META_CTRL_ON      This mask is used to check whether one of the CTRL meta keys is pressed.         4096
META_CTRL_RIGHT_ON   This mask is used to check whether the right CTRL meta key is pressed.            16384
META_FUNCTION_ON   This mask is used to check whether the FUNCTION meta key is pressed.            8
META_META_LEFT_ON   This mask is used to check whether the left META meta key is pressed.            131072
META_META_MASK      This mask is a combination of META_META_ON, META_META_LEFT_ON and META_META_RIGHT_ON.      458752
META_META_ON      This mask is used to check whether one of the META meta keys is pressed.         65536
META_META_RIGHT_ON   This mask is used to check whether the right META meta key is pressed.            262144
META_NUM_LOCK_ON   This mask is used to check whether the NUM LOCK meta key is on.               2097152
META_SCROLL_LOCK_ON   This mask is used to check whether the SCROLL LOCK meta key is on.            4194304
META_SHIFT_LEFT_ON   This mask is used to check whether the left SHIFT meta key is pressed.            64
META_SHIFT_MASK      This mask is a combination of META_SHIFT_ON, META_SHIFT_LEFT_ON and META_SHIFT_RIGHT_ON.   193
META_SHIFT_ON      This mask is used to check whether one of the SHIFT meta keys is pressed.         1
META_SHIFT_RIGHT_ON   This mask is used to check whether the right SHIFT meta key is pressed.            128
META_SYM_ON      This mask is used to check whether the SYM meta key is pressed.               4

KEYCODE_APOSTROPHE   ''' key.   75
KEYCODE_AT      '@' key.   77
KEYCODE_BACKSLASH   '\' key.   73
KEYCODE_COMMA      ',' key.   55
KEYCODE_EQUALS      '=' key.   70
KEYCODE_GRAVE      '`' key.   68
KEYCODE_LEFT_BRACKET   '[' key.   71
KEYCODE_MINUS      '-' key.   69
KEYCODE_PERIOD      '.' key.   56
KEYCODE_PLUS      '+' key.   81
KEYCODE_POUND      '#' key.   18
KEYCODE_RIGHT_BRACKET   ']' key.   72
KEYCODE_SEMICOLON   ';' key.   74
KEYCODE_SLASH      '/' key.   76
KEYCODE_STAR      '*' key.   17
KEYCODE_SPACE      Space key.   62
KEYCODE_TAB      Tab key.   61

KEYCODE_ENTER      Enter key.      66
KEYCODE_ESCAPE      Escape key.      111
KEYCODE_CAPS_LOCK   Caps Lock key.      115
KEYCODE_CLEAR      Clear key.      28
KEYCODE_PAGE_DOWN   Page Down key.      93
KEYCODE_PAGE_UP      Page Up key.      92
KEYCODE_SCROLL_LOCK   Scroll Lock key.   116
KEYCODE_MOVE_END   End.         123
KEYCODE_MOVE_HOME   Home.         122
KEYCODE_INSERT      Insert key.      124
KEYCODE_SHIFT_LEFT   Left Shift.      59
KEYCODE_SHIFT_RIGHT   Right Shift.      60

KEYCODE_F1   F1 key.      131
KEYCODE_F2   F2 key.      132
KEYCODE_F3   F3 key.      133
KEYCODE_F4   F4 key.      134
KEYCODE_F5   F5 key.      135
KEYCODE_F6   F6 key.      136
KEYCODE_F7   F7 key.      137
KEYCODE_F8   F8 key.      138
KEYCODE_F9   F9 key.      139
KEYCODE_F10   F10 key.   140
KEYCODE_F11   F11 key.   141
KEYCODE_F12   F12 key.   142

KEYCODE_BACK      Back key.      4
KEYCODE_CALL      Call key.      5
KEYCODE_ENDCALL      End Call key.      6
KEYCODE_CAMERA      Camera key.      27
KEYCODE_FOCUS      Camera Focus key.   80
KEYCODE_VOLUME_UP   Volume Up key.      24
KEYCODE_VOLUME_DOWN   Volume Down key.   25
KEYCODE_VOLUME_MUTE   Volume Mute key.   164
KEYCODE_MENU      Menu key.      82
KEYCODE_HOME      Home key.      3
KEYCODE_POWER      Power key.      26
KEYCODE_SEARCH      Search key.      84
KEYCODE_NOTIFICATION   Notification key.   83
KEYCODE_NUM      Number modifier key.   78
KEYCODE_SYM      Symbol modifier key.   63
KEYCODE_SETTINGS   Settings key.      176

KEYCODE_DEL      Backspace key. Deletes characters before the insertion point, unlike KEYCODE_FORWARD_DEL.   67
KEYCODE_FORWARD_DEL   Forward Delete key. Deletes characters ahead of the insertion point, unlike KEYCODE_DEL.   112

KEYCODE_NUMPAD_0      Numeric keypad '0' key.      144
KEYCODE_NUMPAD_1      Numeric keypad '1' key.      145
KEYCODE_NUMPAD_2      Numeric keypad '2' key.      146
KEYCODE_NUMPAD_3      Numeric keypad '3' key.      147
KEYCODE_NUMPAD_4      Numeric keypad '4' key.      148
KEYCODE_NUMPAD_5      Numeric keypad '5' key.      149
KEYCODE_NUMPAD_6      Numeric keypad '6' key.      150
KEYCODE_NUMPAD_7      Numeric keypad '7' key.      151
KEYCODE_NUMPAD_8      Numeric keypad '8' key.      152
KEYCODE_NUMPAD_9      Numeric keypad '9' key.      153
KEYCODE_NUMPAD_ADD      Numeric keypad '+' key       157
KEYCODE_NUMPAD_COMMA      Numeric keypad ',' key       159
KEYCODE_NUMPAD_DIVIDE      Numeric keypad '/' key       154
KEYCODE_NUMPAD_DOT      Numeric keypad '.' key       158
KEYCODE_NUMPAD_EQUALS      Numeric keypad '=' key.      161
KEYCODE_NUMPAD_LEFT_PAREN   Numeric keypad '(' key.      162
KEYCODE_NUMPAD_MULTIPLY      Numeric keypad '*' key      155
KEYCODE_NUMPAD_RIGHT_PAREN   Numeric keypad ')' key.      163
KEYCODE_NUMPAD_SUBTRACT      Numeric keypad '-' key      156
KEYCODE_NUMPAD_ENTER      Numeric keypad Enter key.   160
KEYCODE_NUM_LOCK      Numeric keypad Num Lock key.   143


KEYCODE_MEDIA_FAST_FORWARD   Fast Forward media key.      90
KEYCODE_MEDIA_NEXT      Play Next media key.      87
KEYCODE_MEDIA_PAUSE      Pause media key.      127
KEYCODE_MEDIA_PLAY      Play media key.         126
KEYCODE_MEDIA_PLAY_PAUSE   Play/Pause media key.      85
KEYCODE_MEDIA_PREVIOUS      Play Previous media key.   88
KEYCODE_MEDIA_RECORD      Record media key.      130
KEYCODE_MEDIA_REWIND      Rewind media key.      89
KEYCODE_MEDIA_STOP      Stop media key.         86

[Jenkins] 自動寄送mail的格式

使用Email-ext plugin 可以自訂email格式
https://wiki.jenkins-ci.org/display/JENKINS/Email-ext+plugin

將格式檔案放在/var/jenkins/email-templates  資料夾底下   (email-templates要自己創)



[Appium] 使用Appium Inspector

Appium Inspector: 一個appium的工具,可以即時分析目前device畫面上的元件


下載appium.app (from官網)後可以使用(點放大鏡)

執行前必須先建立appium連線,且必須使用port4725(Inspector好像只監聽這個port)

記得把timeout時間設長,不然還沒找完你要的資訊就會因為timeout,appium session斷掉app就被close了



public class inmac {
public static void main(String[] args) throws InterruptedException {
AndroidDriver wd = null;
try {
wd = new AndroidDriver(new URL("http://127.0.0.1:4725/wd/hub"),
App.AppSet());
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}




wd.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);

System.out.println("11");







}
}


[Mac] Mac設定ANDROID_HOME

打開bash_profile


open ~/.bash_profile


輸入:

export PATH=${PATH}:/Users/zhangnaiyuan/Downloads/adt-bundle-mac-x86_64-20140702/sdk/
export ANDROID_HOME=/Users/zhangnaiyuan/Downloads/adt-bundle-mac-x86_64-20140702/sdk/
export PATH=$PATH:$ANDROID_HOME/bin

輸入echo $ANDROID_HOME測試結果 (terminal要重開)

chounomotos-MacBook-Air:~ zhangnaiyuan$ echo $ANDROID_HOME
/Users/zhangnaiyuan/Downloads/adt-bundle-mac-x86_64-20140702/sdk/

[Mac] Mac安裝adb

http://htc-one.wonderhowto.com/how-to/install-adb-fastboot-mac-os-x-send-commands-your-htc-one-0151178/

  1. Download this Android.zip file to your Mac.
  2. Extract the .zip and place the Android folder on your Desktop.
  3. Open Terminal and type: cd Desktop/Android
  4. Now install ADB and Fastboot: ./ADB-Install-Mac.sh
  5. Allow the script to run and you'll be all set. Now the ADB and Fastboot files will be placed in /usr/bin/ on your Mac.

[Jenkins] Jenkins變數 (mail中可使用)

https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project


Jenkins Set Environment Variables

When a Jenkins job executes, it sets some environment variables that you may use in your shell script, batch command, Ant script or Maven POM 1. The following table contains a list of all of these environment variables.
Environment VariableDescription
BUILD_NUMBERThe current build number, such as "153"
BUILD_IDThe current build id, such as "2005-08-22_23-59-59" (YYYY-MM-DD_hh-mm-ss)
BUILD_URL The URL where the results of this build can be found (e.g. http://buildserver/jenkins/job/MyJobName/666/)
NODE_NAMEThe name of the node the current build is running on. Equals 'master' for master node.
JOB_NAMEName of the project of this build. This is the name you gave your job when you first set it up. It's the third column of the Jenkins Dashboard main page.
BUILD_TAGString of jenkins-${JOB_NAME}-${BUILD_NUMBER}. Convenient to put into a resource file, a jar file, etc for easier identification.
JENKINS_URLSet to the URL of the Jenkins master that's running the build. This value is used by Jenkins CLI for example
EXECUTOR_NUMBERThe unique number that identifies the current executor (among executors of the same machine) that's carrying out this build. This is the number you see in the "build executor status", except that the number starts from 0, not 1.
JAVA_HOMEIf your job is configured to use a specific JDK, this variable is set to the JAVA_HOME of the specified JDK. When this variable is set, PATH is also updated to have $JAVA_HOME/bin.
WORKSPACEThe absolute path of the workspace.
SVN_REVISIONFor Subversion-based projects, this variable contains the revision number of the module. If you have more than one module specified, this won't be set. 
CVS_BRANCHFor CVS-based projects, this variable contains the branch of the module. If CVS is configured to check out the trunk, this environment variable will not be set.
GIT_COMMIT For Git-based projects, this variable contains the Git hash of the commit checked out for the build (like ce9a3c1404e8c91be604088670e93434c4253f03) (all the GIT_* variables require git plugin)     
GIT_URLFor Git-based projects, this variable contains the Git url (like git@github.com:user/repo.git or https://github.com/user/repo.git)\\
GIT_BRANCH For Git-based projects, this variable contains the Git branch that was checked out for the build (normally origin/master) 

Promoted Build Plugin Environment Variables

If you are using the Promoted Build Plugin, you will have access to the following environment variables. This allows you to access information about your Jenkins build since certain environment variables stated above (such as BUILD_TAG now refer to the Promoted Build Plugin's job.
Environment VariableReplacesDescription
PROMOTED_URLBUILD_URLThe URL of the original Jenkins job that is involved with the promotion. BUILD_URL now refers to the Promotion's URL
PROMOTED_JOB_NAMEJOB_NAMEThe name of the original Jenkins job that is involved with the promotion. JOB_NAME now refers to the Promotion's job's name
PROMOTED_NUMBERBUILD_NUMBERThe Build Number of the job being promoted. BUILD_NUMBER now refer's the the Promotion Number
PROMOTED_IDBUILD_IDThe Build ID (ex. "2005-08-22_23-59-59" (YYYY-MM-DD_hh-mm-ss) ) of the original Jenkins job. BUILD_ID now refer's to the Promotion's build ID.

[Appium] 使用CI+Appium收集log

1258
gigayaya 1楼 · 9天前 喜欢  
我也有這個問題,appium log在sever啟動時就建立了。換句話說,如果你的server沒有重啟過,那不管你跑多少條test case都會存在同一個log,不僅檔案會越來越大,也會越來越難撈你要的資料。
我目前的做法是,用Jenkins控制整個流程,如下:
  1. 啟動test project
  2. test project一啟動先刪除workspace下所有東西
  3. test project通過git獲得code
  4. test project啟動appium project
  5. appium project啟動appium server
  6. appium server啟動,將log存到test project的workspace中
  7. 執行test case
  8. 結束,上傳test report跟appium log
  9. 設置timeout,appium project閒置過久自動close project

[Appium] 安裝失敗

“
npm ERR! Error: EACCES, symlink '../lib/node_modules/appium/bin/appium.js'
npm ERR!  { [Error: EACCES, symlink '../lib/node_modules/appium/bin/appium.js']
npm ERR!   errno: 3,
npm ERR!   code: 'EACCES',
npm ERR!   path: '../lib/node_modules/appium/bin/appium.js' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Darwin 13.2.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "-g" "appium"
npm ERR! cwd /Users/yytest
npm ERR! node -v v0.10.29
npm ERR! npm -v 1.4.14
npm ERR! path ../lib/node_modules/appium/bin/appium.js
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, symlink '../lib/node_modules/appium/bin/appium.js'
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/yytest/npm-debug.log
npm ERR! not ok code 0
”

問題:Node沒有得到該資料夾的權限

解決:


sudo chown -R $USER /usr/local






[Appium] 根據一個已找到的位置,往下尋找子結點

如果我的目標是這裡:
xpath: //UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[6]/UIASwitch[1]
那code應該是這樣:
WebElement aa = wd.findElement(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIATableView[1]"));
List<WebElement> bb= aa.findElements(By.className("UIATableCell"));
WebElement cc = bb.get(5);
WebElement dd = cc.findElement(By.className("UIASwitch"));

dd.click();
列出某一節點下面全部元素(不過無法顯示元素類別):

code:
List<WebElement> wblist= wd.findElements(By.xpath("//UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*"));
System.out.println(wblist);
output:
[[[AppiumDriver: iOS on MAC (] -> xpath: //UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*], [[AppiumDriver: iOS on MAC ()] -> xpath: //UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*], [[AppiumDriver: iOS on MAC ()] -> xpath: //UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*], [[AppiumDriver: iOS on MAC ()] -> xpath: //UIAApplication[1]/UIAWindow[1]/UIATableView[1]/*]]