Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Aniona
java-client
提交
9e59b56b
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,发现更多精彩内容 >>
未验证
提交
9e59b56b
编写于
7月 09, 2020
作者:
M
Mykola Mokhnach
提交者:
GitHub
7月 09, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: Parse platformName if it is passed as enum item (#1369)
上级
b31a6d8d
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
36 addition
and
51 deletion
+36
-51
azure-pipelines.yml
azure-pipelines.yml
+5
-5
src/main/java/io/appium/java_client/AppiumDriver.java
src/main/java/io/appium/java_client/AppiumDriver.java
+3
-1
src/main/java/io/appium/java_client/internal/CapabilityHelpers.java
...ava/io/appium/java_client/internal/CapabilityHelpers.java
+8
-2
src/main/java/io/appium/java_client/internal/JsonToMobileElementConverter.java
...um/java_client/internal/JsonToMobileElementConverter.java
+4
-2
src/main/java/io/appium/java_client/pagefactory/AppiumFieldDecorator.java
.../appium/java_client/pagefactory/AppiumFieldDecorator.java
+13
-19
src/test/java/io/appium/java_client/ios/IOSTouchTest.java
src/test/java/io/appium/java_client/ios/IOSTouchTest.java
+3
-22
未找到文件。
azure-pipelines.yml
浏览文件 @
9e59b56b
...
@@ -4,24 +4,24 @@
...
@@ -4,24 +4,24 @@
# https://docs.microsoft.com/azure/devops/pipelines/languages/java
# https://docs.microsoft.com/azure/devops/pipelines/languages/java
pool
:
pool
:
vmImage
:
'
macOS
10.14
'
vmImage
:
'
macOS
-10.15
'
variables
:
variables
:
ANDROID_EMU_NAME
:
test
ANDROID_EMU_NAME
:
test
ANDROID_EMU_ABI
:
x86
ANDROID_EMU_ABI
:
x86
ANDROID_EMU_TARGET
:
android-27
ANDROID_EMU_TARGET
:
android-27
ANDROID_EMU_TAG
:
google_apis
ANDROID_EMU_TAG
:
google_apis
XCODE_VERSION
:
1
0.2
XCODE_VERSION
:
1
1.5
IOS_PLATFORM_VERSION
:
1
2.2
IOS_PLATFORM_VERSION
:
1
3.5
IOS_DEVICE_NAME
:
iPhone X
IOS_DEVICE_NAME
:
iPhone X
jobs
:
jobs
:
-
job
:
E2E_Tests
-
job
:
E2E_Tests
timeoutInMinutes
:
60
timeoutInMinutes
:
'
60'
steps
:
steps
:
-
task
:
NodeTool@0
-
task
:
NodeTool@0
inputs
:
inputs
:
versionSpec
:
'
1
1
.x'
versionSpec
:
'
1
2
.x'
-
script
:
|
-
script
:
|
echo "Configuring Environment"
echo "Configuring Environment"
...
...
src/main/java/io/appium/java_client/AppiumDriver.java
浏览文件 @
9e59b56b
...
@@ -40,6 +40,7 @@ import org.openqa.selenium.WebDriverException;
...
@@ -40,6 +40,7 @@ import org.openqa.selenium.WebDriverException;
import
org.openqa.selenium.WebElement
;
import
org.openqa.selenium.WebElement
;
import
org.openqa.selenium.html5.Location
;
import
org.openqa.selenium.html5.Location
;
import
org.openqa.selenium.remote.CapabilityType
;
import
org.openqa.selenium.remote.DesiredCapabilities
;
import
org.openqa.selenium.remote.DesiredCapabilities
;
import
org.openqa.selenium.remote.DriverCommand
;
import
org.openqa.selenium.remote.DriverCommand
;
import
org.openqa.selenium.remote.ErrorHandler
;
import
org.openqa.selenium.remote.ErrorHandler
;
...
@@ -316,7 +317,8 @@ public class AppiumDriver<T extends WebElement>
...
@@ -316,7 +317,8 @@ public class AppiumDriver<T extends WebElement>
@Override
@Override
public
boolean
isBrowser
()
{
public
boolean
isBrowser
()
{
String
browserName
=
CapabilityHelpers
.
getCapability
(
getCapabilities
(),
"browserName"
,
String
.
class
);
String
browserName
=
CapabilityHelpers
.
getCapability
(
getCapabilities
(),
CapabilityType
.
BROWSER_NAME
,
String
.
class
);
if
(!
isBlank
(
browserName
))
{
if
(!
isBlank
(
browserName
))
{
try
{
try
{
return
(
boolean
)
executeScript
(
"return !!window.navigator;"
);
return
(
boolean
)
executeScript
(
"return !!window.navigator;"
);
...
...
src/main/java/io/appium/java_client/internal/CapabilityHelpers.java
浏览文件 @
9e59b56b
...
@@ -43,8 +43,14 @@ public class CapabilityHelpers {
...
@@ -43,8 +43,14 @@ public class CapabilityHelpers {
possibleNames
.
add
(
APPIUM_PREFIX
+
name
);
possibleNames
.
add
(
APPIUM_PREFIX
+
name
);
}
}
for
(
String
capName
:
possibleNames
)
{
for
(
String
capName
:
possibleNames
)
{
if
(
caps
.
getCapability
(
capName
)
!=
null
if
(
caps
.
getCapability
(
capName
)
==
null
)
{
&&
expectedType
.
isAssignableFrom
(
caps
.
getCapability
(
capName
).
getClass
()))
{
continue
;
}
if
(
expectedType
==
String
.
class
)
{
return
expectedType
.
cast
(
String
.
valueOf
(
caps
.
getCapability
(
capName
)));
}
if
(
expectedType
.
isAssignableFrom
(
caps
.
getCapability
(
capName
).
getClass
()))
{
return
expectedType
.
cast
(
caps
.
getCapability
(
capName
));
return
expectedType
.
cast
(
caps
.
getCapability
(
capName
));
}
}
}
}
...
...
src/main/java/io/appium/java_client/internal/JsonToMobileElementConverter.java
浏览文件 @
9e59b56b
...
@@ -18,8 +18,10 @@ package io.appium.java_client.internal;
...
@@ -18,8 +18,10 @@ package io.appium.java_client.internal;
import
static
io
.
appium
.
java_client
.
internal
.
ElementMap
.
getElementClass
;
import
static
io
.
appium
.
java_client
.
internal
.
ElementMap
.
getElementClass
;
import
io.appium.java_client.remote.MobileCapabilityType
;
import
org.openqa.selenium.Capabilities
;
import
org.openqa.selenium.Capabilities
;
import
org.openqa.selenium.WebDriverException
;
import
org.openqa.selenium.WebDriverException
;
import
org.openqa.selenium.remote.CapabilityType
;
import
org.openqa.selenium.remote.RemoteWebDriver
;
import
org.openqa.selenium.remote.RemoteWebDriver
;
import
org.openqa.selenium.remote.RemoteWebElement
;
import
org.openqa.selenium.remote.RemoteWebElement
;
import
org.openqa.selenium.remote.internal.JsonToWebElementConverter
;
import
org.openqa.selenium.remote.internal.JsonToWebElementConverter
;
...
@@ -46,8 +48,8 @@ public class JsonToMobileElementConverter extends JsonToWebElementConverter {
...
@@ -46,8 +48,8 @@ public class JsonToMobileElementConverter extends JsonToWebElementConverter {
super
(
driver
);
super
(
driver
);
this
.
driver
=
driver
;
this
.
driver
=
driver
;
Capabilities
caps
=
driver
.
getCapabilities
();
Capabilities
caps
=
driver
.
getCapabilities
();
this
.
platform
=
CapabilityHelpers
.
getCapability
(
caps
,
"platformName"
,
String
.
class
);
this
.
platform
=
CapabilityHelpers
.
getCapability
(
caps
,
CapabilityType
.
PLATFORM_NAME
,
String
.
class
);
this
.
automation
=
CapabilityHelpers
.
getCapability
(
caps
,
"automationName"
,
String
.
class
);
this
.
automation
=
CapabilityHelpers
.
getCapability
(
caps
,
MobileCapabilityType
.
AUTOMATION_NAME
,
String
.
class
);
}
}
@Override
@Override
...
...
src/main/java/io/appium/java_client/pagefactory/AppiumFieldDecorator.java
浏览文件 @
9e59b56b
...
@@ -29,13 +29,14 @@ import io.appium.java_client.internal.CapabilityHelpers;
...
@@ -29,13 +29,14 @@ import io.appium.java_client.internal.CapabilityHelpers;
import
io.appium.java_client.ios.IOSElement
;
import
io.appium.java_client.ios.IOSElement
;
import
io.appium.java_client.pagefactory.bys.ContentType
;
import
io.appium.java_client.pagefactory.bys.ContentType
;
import
io.appium.java_client.pagefactory.locator.CacheableLocator
;
import
io.appium.java_client.pagefactory.locator.CacheableLocator
;
import
io.appium.java_client.remote.MobileCapabilityType
;
import
io.appium.java_client.windows.WindowsElement
;
import
io.appium.java_client.windows.WindowsElement
;
import
org.openqa.selenium.Capabilities
;
import
org.openqa.selenium.Capabilities
;
import
org.openqa.selenium.HasCapabilities
;
import
org.openqa.selenium.HasCapabilities
;
import
org.openqa.selenium.SearchContext
;
import
org.openqa.selenium.SearchContext
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.WebElement
;
import
org.openqa.selenium.WebElement
;
import
org.openqa.selenium.remote.
RemoteWebDriver
;
import
org.openqa.selenium.remote.
CapabilityType
;
import
org.openqa.selenium.remote.RemoteWebElement
;
import
org.openqa.selenium.remote.RemoteWebElement
;
import
org.openqa.selenium.support.pagefactory.DefaultFieldDecorator
;
import
org.openqa.selenium.support.pagefactory.DefaultFieldDecorator
;
import
org.openqa.selenium.support.pagefactory.ElementLocator
;
import
org.openqa.selenium.support.pagefactory.ElementLocator
;
...
@@ -49,6 +50,7 @@ import java.lang.reflect.TypeVariable;
...
@@ -49,6 +50,7 @@ import java.lang.reflect.TypeVariable;
import
java.time.Duration
;
import
java.time.Duration
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Arrays
;
import
java.util.Collections
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -88,8 +90,8 @@ public class AppiumFieldDecorator implements FieldDecorator {
...
@@ -88,8 +90,8 @@ public class AppiumFieldDecorator implements FieldDecorator {
if
(
this
.
webDriver
instanceof
HasCapabilities
)
{
if
(
this
.
webDriver
instanceof
HasCapabilities
)
{
Capabilities
caps
=
((
HasCapabilities
)
this
.
webDriver
).
getCapabilities
();
Capabilities
caps
=
((
HasCapabilities
)
this
.
webDriver
).
getCapabilities
();
this
.
platform
=
CapabilityHelpers
.
getCapability
(
caps
,
"platformName"
,
String
.
class
);
this
.
platform
=
CapabilityHelpers
.
getCapability
(
caps
,
CapabilityType
.
PLATFORM_NAME
,
String
.
class
);
this
.
automation
=
CapabilityHelpers
.
getCapability
(
caps
,
"automationName"
,
String
.
class
);
this
.
automation
=
CapabilityHelpers
.
getCapability
(
caps
,
MobileCapabilityType
.
AUTOMATION_NAME
,
String
.
class
);
}
else
{
}
else
{
this
.
platform
=
null
;
this
.
platform
=
null
;
this
.
automation
=
null
;
this
.
automation
=
null
;
...
@@ -107,8 +109,7 @@ public class AppiumFieldDecorator implements FieldDecorator {
...
@@ -107,8 +109,7 @@ public class AppiumFieldDecorator implements FieldDecorator {
@Override
@Override
@SuppressWarnings
(
"unchecked"
)
@SuppressWarnings
(
"unchecked"
)
protected
List
<
WebElement
>
proxyForListLocator
(
ClassLoader
ignored
,
protected
List
<
WebElement
>
proxyForListLocator
(
ClassLoader
ignored
,
ElementLocator
locator
)
{
ElementLocator
locator
)
{
ElementListInterceptor
elementInterceptor
=
new
ElementListInterceptor
(
locator
);
ElementListInterceptor
elementInterceptor
=
new
ElementListInterceptor
(
locator
);
return
getEnhancedProxy
(
ArrayList
.
class
,
elementInterceptor
);
return
getEnhancedProxy
(
ArrayList
.
class
,
elementInterceptor
);
}
}
...
@@ -125,19 +126,12 @@ public class AppiumFieldDecorator implements FieldDecorator {
...
@@ -125,19 +126,12 @@ public class AppiumFieldDecorator implements FieldDecorator {
}
}
Type
listType
=
((
ParameterizedType
)
genericType
).
getActualTypeArguments
()[
0
];
Type
listType
=
((
ParameterizedType
)
genericType
).
getActualTypeArguments
()[
0
];
List
<
Type
>
bounds
=
(
listType
instanceof
TypeVariable
)
?
Arrays
.
asList
(((
TypeVariable
<?>)
listType
).
getBounds
())
:
Collections
.
emptyList
();
for
(
Class
<?
extends
WebElement
>
webElementClass
:
availableElementClasses
)
{
return
availableElementClasses
.
stream
()
if
(
webElementClass
.
equals
(
listType
))
{
.
anyMatch
((
webElClass
)
->
webElClass
.
equals
(
listType
)
||
bounds
.
contains
(
webElClass
));
return
true
;
}
}
if
((
listType
instanceof
TypeVariable
)
&&
Arrays
.
asList
(((
TypeVariable
<?>)
listType
).
getBounds
())
.
stream
().
anyMatch
(
item
->
availableElementClasses
.
contains
(
item
)))
{
return
true
;
}
return
false
;
}
}
};
};
...
@@ -188,10 +182,10 @@ public class AppiumFieldDecorator implements FieldDecorator {
...
@@ -188,10 +182,10 @@ public class AppiumFieldDecorator implements FieldDecorator {
}
}
if
(
listType
instanceof
Class
)
{
if
(
listType
instanceof
Class
)
{
if
(!
Widget
.
class
.
isAssignableFrom
((
Class
)
listType
))
{
if
(!
Widget
.
class
.
isAssignableFrom
((
Class
<?>
)
listType
))
{
return
null
;
return
null
;
}
}
widgetType
=
Class
.
class
.
cast
(
listType
)
;
widgetType
=
(
Class
<?
extends
Widget
>)
listType
;
}
else
{
}
else
{
return
null
;
return
null
;
}
}
...
...
src/test/java/io/appium/java_client/ios/IOSTouchTest.java
浏览文件 @
9e59b56b
...
@@ -5,7 +5,6 @@ import static io.appium.java_client.touch.TapOptions.tapOptions;
...
@@ -5,7 +5,6 @@ import static io.appium.java_client.touch.TapOptions.tapOptions;
import
static
io
.
appium
.
java_client
.
touch
.
WaitOptions
.
waitOptions
;
import
static
io
.
appium
.
java_client
.
touch
.
WaitOptions
.
waitOptions
;
import
static
io
.
appium
.
java_client
.
touch
.
offset
.
ElementOption
.
element
;
import
static
io
.
appium
.
java_client
.
touch
.
offset
.
ElementOption
.
element
;
import
static
java
.
time
.
Duration
.
ofMillis
;
import
static
java
.
time
.
Duration
.
ofMillis
;
import
static
java
.
time
.
Duration
.
ofSeconds
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
junit
.
Assert
.
assertNotNull
;
import
static
org
.
openqa
.
selenium
.
support
.
ui
.
ExpectedConditions
.
alertIsPresent
;
import
static
org
.
openqa
.
selenium
.
support
.
ui
.
ExpectedConditions
.
alertIsPresent
;
...
@@ -13,11 +12,9 @@ import static org.openqa.selenium.support.ui.ExpectedConditions.alertIsPresent;
...
@@ -13,11 +12,9 @@ import static org.openqa.selenium.support.ui.ExpectedConditions.alertIsPresent;
import
io.appium.java_client.MobileElement
;
import
io.appium.java_client.MobileElement
;
import
io.appium.java_client.MultiTouchAction
;
import
io.appium.java_client.MultiTouchAction
;
import
io.appium.java_client.TouchAction
;
import
io.appium.java_client.TouchAction
;
import
io.appium.java_client.touch.offset.ElementOption
;
import
org.junit.FixMethodOrder
;
import
org.junit.FixMethodOrder
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.junit.runners.MethodSorters
;
import
org.junit.runners.MethodSorters
;
import
org.openqa.selenium.Dimension
;
import
org.openqa.selenium.support.ui.WebDriverWait
;
import
org.openqa.selenium.support.ui.WebDriverWait
;
@FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
@FixMethodOrder
(
MethodSorters
.
NAME_ASCENDING
)
...
@@ -33,7 +30,7 @@ public class IOSTouchTest extends AppIOSTest {
...
@@ -33,7 +30,7 @@ public class IOSTouchTest extends AppIOSTest {
intB
.
sendKeys
(
"4"
);
intB
.
sendKeys
(
"4"
);
MobileElement
e
=
driver
.
findElementByAccessibilityId
(
"ComputeSumButton"
);
MobileElement
e
=
driver
.
findElementByAccessibilityId
(
"ComputeSumButton"
);
new
TouchAction
(
driver
).
tap
(
tapOptions
().
withElement
(
element
(
e
))).
perform
();
new
IOS
TouchAction
(
driver
).
tap
(
tapOptions
().
withElement
(
element
(
e
))).
perform
();
assertEquals
(
driver
.
findElementByXPath
(
"//*[@name = \"Answer\"]"
).
getText
(),
"6"
);
assertEquals
(
driver
.
findElementByXPath
(
"//*[@name = \"Answer\"]"
).
getText
(),
"6"
);
}
}
...
@@ -57,28 +54,12 @@ public class IOSTouchTest extends AppIOSTest {
...
@@ -57,28 +54,12 @@ public class IOSTouchTest extends AppIOSTest {
assertEquals
(
driver
.
findElementByXPath
(
"//*[@name = \"Answer\"]"
).
getText
(),
"6"
);
assertEquals
(
driver
.
findElementByXPath
(
"//*[@name = \"Answer\"]"
).
getText
(),
"6"
);
}
}
@Test
public
void
swipeTest
()
{
WebDriverWait
webDriverWait
=
new
WebDriverWait
(
driver
,
30
);
IOSElement
slider
=
webDriverWait
.
until
(
driver1
->
driver
.
findElementByClassName
(
"XCUIElementTypeSlider"
));
Dimension
size
=
slider
.
getSize
();
ElementOption
press
=
element
(
slider
,
size
.
width
/
2
+
2
,
size
.
height
/
2
);
ElementOption
move
=
element
(
slider
,
1
,
size
.
height
/
2
);
TouchAction
swipe
=
new
TouchAction
(
driver
).
press
(
press
)
.
waitAction
(
waitOptions
(
ofSeconds
(
2
)))
.
moveTo
(
move
).
release
();
swipe
.
perform
();
assertEquals
(
"0%"
,
slider
.
getAttribute
(
"value"
));
}
@Test
public
void
multiTouchTest
()
{
@Test
public
void
multiTouchTest
()
{
MobileElement
e
=
driver
.
findElementByAccessibilityId
(
"ComputeSumButton"
);
MobileElement
e
=
driver
.
findElementByAccessibilityId
(
"ComputeSumButton"
);
MobileElement
e2
=
driver
.
findElementByAccessibilityId
(
"show alert"
);
MobileElement
e2
=
driver
.
findElementByAccessibilityId
(
"show alert"
);
TouchAction
tap1
=
new
TouchAction
(
driver
).
tap
(
tapOptions
().
withElement
(
element
(
e
)));
IOSTouchAction
tap1
=
new
IOS
TouchAction
(
driver
).
tap
(
tapOptions
().
withElement
(
element
(
e
)));
TouchAction
tap2
=
new
TouchAction
(
driver
).
tap
(
tapOptions
().
withElement
(
element
(
e2
)));
IOSTouchAction
tap2
=
new
IOS
TouchAction
(
driver
).
tap
(
tapOptions
().
withElement
(
element
(
e2
)));
new
MultiTouchAction
(
driver
).
add
(
tap1
).
add
(
tap2
).
perform
();
new
MultiTouchAction
(
driver
).
add
(
tap1
).
add
(
tap2
).
perform
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录