Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Aniona
java-client
提交
2585bba4
J
java-client
项目概览
Aniona
/
java-client
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
J
java-client
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
2585bba4
编写于
12月 17, 2017
作者:
S
Sergey Tikhomirov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Additional changes of the #473: improvements of FingerPrintTest
上级
0a3f4633
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
60 addition
and
58 deletion
+60
-58
src/test/java/io/appium/java_client/android/FingerPrintTest.java
...t/java/io/appium/java_client/android/FingerPrintTest.java
+60
-58
未找到文件。
src/test/java/io/appium/java_client/android/FingerPrintTest.java
浏览文件 @
2585bba4
...
@@ -16,7 +16,9 @@
...
@@ -16,7 +16,9 @@
package
io.appium.java_client.android
;
package
io.appium.java_client.android
;
import
static
io
.
appium
.
java_client
.
MobileBy
.
AndroidUIAutomator
;
import
static
java
.
util
.
concurrent
.
TimeUnit
.
SECONDS
;
import
static
java
.
util
.
concurrent
.
TimeUnit
.
SECONDS
;
import
static
org
.
openqa
.
selenium
.
By
.
id
;
import
io.appium.java_client.remote.MobileCapabilityType
;
import
io.appium.java_client.remote.MobileCapabilityType
;
import
io.appium.java_client.service.local.AppiumDriverLocalService
;
import
io.appium.java_client.service.local.AppiumDriverLocalService
;
...
@@ -26,20 +28,21 @@ import org.junit.Assert;
...
@@ -26,20 +28,21 @@ import org.junit.Assert;
import
org.junit.Before
;
import
org.junit.Before
;
import
org.junit.BeforeClass
;
import
org.junit.BeforeClass
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.NoSuchElementException
;
import
org.openqa.selenium.NoSuchElementException
;
import
org.openqa.selenium.remote.DesiredCapabilities
;
import
org.openqa.selenium.remote.DesiredCapabilities
;
/**
* It is necessary to make this test passing
* - emulator API Level 23 Nexus device
* - perform 'adb emu finger touch' 1 on Windows
*/
public
class
FingerPrintTest
{
public
class
FingerPrintTest
{
private
static
final
String
PASSWORD_INPUT_ID
=
"com.android.settings:id/password_entry"
;
private
static
final
String
FIRST_IN_LIST_XPATH
=
"//android.widget.ListView[1]/android.widget.LinearLayout[1]"
;
private
static
AppiumDriverLocalService
service
;
private
static
AppiumDriverLocalService
service
;
private
static
AndroidDriver
<
AndroidElement
>
driver
;
private
static
void
initDriver
()
{
DesiredCapabilities
capabilities
=
new
DesiredCapabilities
();
capabilities
.
setCapability
(
MobileCapabilityType
.
DEVICE_NAME
,
"Android Emulator"
);
capabilities
.
setCapability
(
"appPackage"
,
"com.android.settings"
);
capabilities
.
setCapability
(
"appActivity"
,
"Settings"
);
driver
=
new
AndroidDriver
<>(
service
.
getUrl
(),
capabilities
);
driver
.
manage
().
timeouts
().
implicitlyWait
(
15
,
SECONDS
);
}
/**
/**
* initialization.
* initialization.
...
@@ -62,44 +65,59 @@ public class FingerPrintTest {
...
@@ -62,44 +65,59 @@ public class FingerPrintTest {
}
}
}
}
private
AndroidElement
findElementByText
(
String
text
)
{
return
driver
.
findElements
(
id
(
"android:id/title"
)).
stream
().
filter
(
androidElement
->
text
.
equals
(
androidElement
.
getText
())).
findFirst
()
.
orElseThrow
(()
->
new
NoSuchElementException
(
String
.
format
(
"There is no element with the text '%s'"
,
text
)));
}
private
void
clickNext
()
{
driver
.
findElementById
(
"com.android.settings:id/next_button"
).
click
();
}
private
void
clickOKInPopup
()
{
driver
.
findElementById
(
"android:id/button1"
).
click
();
}
private
void
enterPasswordAndContinue
()
{
driver
.
findElementById
(
"com.android.settings:id/password_entry"
)
.
sendKeys
(
"1234\n"
);
}
private
void
clickOnSecurity
()
{
driver
.
findElement
(
AndroidUIAutomator
(
"new UiScrollable(new UiSelector()"
+
".scrollable(true)).scrollIntoView("
+
"new UiSelector().text(\"Security\"));"
)).
click
();
}
/**
/**
* enable system security which is required for finger print activation.
* enable system security which is required for finger print activation.
*/
*/
@Before
public
void
before
()
throws
Exception
{
@Before
public
void
before
()
throws
Exception
{
final
AndroidDriver
driver
=
getAndroidDriver
(
"ChooseLockGeneric"
);
initDriver
();
// clicking the pin lock mode
clickOnSecurity
();
driver
.
findElement
(
By
.
xpath
(
"//android.widget.LinearLayout[4]"
)).
click
();
findElementByText
(
"Screen lock"
).
click
();
try
{
findElementByText
(
"PIN"
).
click
();
// line below will throw exception if secure startup window is popped up
enterPasswordAndContinue
();
driver
.
findElementById
(
PASSWORD_INPUT_ID
);
enterPasswordAndContinue
();
}
catch
(
NoSuchElementException
e
)
{
clickNext
();
// in secure startup window
driver
.
findElementById
(
"com.android.settings:id/encrypt_require_password"
).
click
();
SECONDS
.
sleep
(
2
);
clickOKInPopup
(
driver
);
clickNext
(
driver
);
}
enterPasswordAndContinue
(
driver
);
enterPasswordAndContinue
(
driver
);
clickNext
(
driver
);
driver
.
quit
();
}
}
/**
/**
* add a new finger print to security.
* add a new finger print to security.
*/
*/
@Test
public
void
pressKeyCodeTest
()
throws
InterruptedException
{
@Test
public
void
fingerPrintTest
()
{
final
AndroidDriver
driver
=
getAndroidDriver
(
".fingerprint.FingerprintSettings"
);
findElementByText
(
"Fingerprint"
).
click
();
enterPasswordAndContinue
(
driver
);
clickNext
();
// click add fingerprint
enterPasswordAndContinue
();
driver
.
findElementByXPath
(
FIRST_IN_LIST_XPATH
).
click
();
clickNext
();
driver
.
fingerPrint
(
2
);
driver
.
fingerPrint
(
2
);
try
{
try
{
clickNext
(
driver
);
driver
.
findElementById
(
"com.android.settings:id/next_button"
).
click
(
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
Assert
.
fail
(
"fingerprint command fail to execute"
);
Assert
.
fail
(
"fingerprint command fail to execute"
);
}
finally
{
driver
.
quit
();
}
}
}
}
...
@@ -107,32 +125,16 @@ public class FingerPrintTest {
...
@@ -107,32 +125,16 @@ public class FingerPrintTest {
* disabling pin lock mode.
* disabling pin lock mode.
*/
*/
@After
public
void
after
()
throws
InterruptedException
{
@After
public
void
after
()
throws
InterruptedException
{
final
AndroidDriver
driver
=
getAndroidDriver
(
"ChooseLockGeneric"
);
enterPasswordAndContinue
(
driver
);
driver
.
findElementByXPath
(
FIRST_IN_LIST_XPATH
).
click
();
clickOKInPopup
(
driver
);
driver
.
quit
();
driver
.
quit
();
}
private
static
AndroidDriver
getAndroidDriver
(
String
activity
)
{
DesiredCapabilities
capabilities
=
new
DesiredCapabilities
();
capabilities
.
setCapability
(
MobileCapabilityType
.
DEVICE_NAME
,
"Android Emulator"
);
capabilities
.
setCapability
(
"appPackage"
,
"com.android.settings"
);
capabilities
.
setCapability
(
"appActivity"
,
activity
);
AndroidDriver
<
AndroidElement
>
driver
=
new
AndroidDriver
<
AndroidElement
>(
service
.
getUrl
(),
capabilities
);
driver
.
manage
().
timeouts
().
implicitlyWait
(
15
,
SECONDS
);
return
driver
;
}
private
void
enterPasswordAndContinue
(
AndroidDriver
driver
)
throws
InterruptedException
{
initDriver
();
driver
.
findElementById
(
PASSWORD_INPUT_ID
).
sendKeys
(
"1234\n"
);
clickOnSecurity
();
}
private
void
clickNext
(
AndroidDriver
driver
)
throws
InterruptedException
{
findElementByText
(
"Screen lock"
).
click
();
driver
.
findElementById
(
"com.android.settings:id/next_button"
).
click
();
}
private
void
clickOKInPopup
(
AndroidDriver
driver
)
throws
InterruptedException
{
enterPasswordAndContinue
();
driver
.
findElementById
(
"android:id/button1"
).
click
();
findElementByText
(
"None"
).
click
();
clickOKInPopup
();
driver
.
quit
();
}
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录