Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
test-platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
马博
test-platform
Commits
77052a56
Commit
77052a56
authored
Nov 26, 2018
by
钱雯君
Browse files
Options
Browse Files
Download
Plain Diff
add
parents
16ae2c84
e51e08f1
Changes
23
Show whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
462 additions
and
52 deletions
+462
-52
pom.xml
pom.xml
+1
-0
DuibaBase.java
src/test/java/base/DuibaBase.java
+3
-1
DuibaBaseUi.java
src/test/java/base/DuibaBaseUi.java
+200
-0
CustomActivity_DuibaTest.java
...p/cases/DefinedActivityTest/CustomActivity_DuibaTest.java
+1
-1
修改兑吧商品_ExchangeTest.java
...ava/http/cases/GoodsAndTradeTest/修改兑吧商品_ExchangeTest.java
+2
-2
商品管理操作_ExchangeTest.java
...ava/http/cases/GoodsAndTradeTest/商品管理操作_ExchangeTest.java
+2
-2
异常订单测试_ExchangeTest.java
...ava/http/cases/GoodsAndTradeTest/异常订单测试_ExchangeTest.java
+2
-2
自有优惠券测试_ExchangeTest.java
...va/http/cases/GoodsAndTradeTest/自有优惠券测试_ExchangeTest.java
+2
-2
自有实物测试_ExchangeTest.java
...ava/http/cases/GoodsAndTradeTest/自有实物测试_ExchangeTest.java
+2
-2
自有虚拟商品测试_ExchangeTest.java
...a/http/cases/GoodsAndTradeTest/自有虚拟商品测试_ExchangeTest.java
+2
-2
优惠券测试_DuibaTest.java
...test/java/http/cases/NewActivityTest/优惠券测试_DuibaTest.java
+1
-1
谢谢参与测试_DuibaTest.java
...est/java/http/cases/NewActivityTest/谢谢参与测试_DuibaTest.java
+1
-0
pk_开奖_瓜分红包测试.java
src/test/java/http/cases/PkTest/pk_开奖_瓜分红包测试.java
+1
-0
开发者签到管理_signTest.java
src/test/java/http/cases/SignTest/开发者签到管理_signTest.java
+2
-2
种红包配置校验_AccessTest.java
src/test/java/http/cases/WalletTest/种红包配置校验_AccessTest.java
+54
-3
优惠券_ExchangeTest_ui.java
src/test/java/ui/cases/Exchange/优惠券_ExchangeTest_ui.java
+33
-0
实物_ExchangeTest_ui.java
src/test/java/ui/cases/Exchange/实物_ExchangeTest_ui.java
+30
-0
支付宝_ExchangeTest_ui.java
src/test/java/ui/cases/Exchange/支付宝_ExchangeTest_ui.java
+30
-0
test.java
src/test/java/ui/cases/test.java
+30
-25
uitest.java
src/test/java/ui/cases/uitest.java
+38
-0
WebDriverFactory.java
src/test/java/ui/common/WebDriverFactory.java
+23
-5
WebDriverType.java
src/test/java/ui/common/WebDriverType.java
+1
-1
duiba.properties
src/test/profiles/aliyun/duiba.properties
+1
-1
No files found.
pom.xml
View file @
77052a56
...
@@ -311,6 +311,7 @@
...
@@ -311,6 +311,7 @@
<run>
${run}
</run>
<run>
${run}
</run>
<maxRetryCount>
0
</maxRetryCount>
<maxRetryCount>
0
</maxRetryCount>
<ServiceDoctor>
false
</ServiceDoctor>
<ServiceDoctor>
false
</ServiceDoctor>
<Server>
false
</Server>
</systemPropertyVariables>
</systemPropertyVariables>
</configuration>
</configuration>
...
...
src/test/java/base/DuibaBase.java
View file @
77052a56
...
@@ -17,9 +17,11 @@ public class DuibaBase extends AbstractTestNGSpringContextTestsDuiba {
...
@@ -17,9 +17,11 @@ public class DuibaBase extends AbstractTestNGSpringContextTestsDuiba {
public
MysqlConnPool
jdbc
;
public
MysqlConnPool
jdbc
;
public
DuibaLog
logger
=
DuibaLog
.
getLogger
();
public
DuibaLog
logger
=
DuibaLog
.
getLogger
();
// @PostConstruct
// @PostConstruct
@BeforeSuite
@BeforeSuite
public
void
setUp
()
{
public
final
void
setUp
()
{
logger
.
info
(
"--------------------DuibaBase.setUp()"
);
logger
.
info
(
"--------------------DuibaBase.setUp()"
);
//只初始化一次
//只初始化一次
jdbc
.
initDataSource
();
jdbc
.
initDataSource
();
...
...
src/test/java/base/DuibaBaseUi.java
0 → 100644
View file @
77052a56
package
base
;
import
com.codeborne.selenide.WebDriverRunner
;
import
org.apache.commons.io.FileUtils
;
import
org.openqa.selenium.By
;
import
org.openqa.selenium.OutputType
;
import
org.openqa.selenium.TakesScreenshot
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.remote.RemoteWebDriver
;
import
org.testng.ITestResult
;
import
org.testng.Reporter
;
import
org.testng.annotations.*
;
import
ui.common.ProxyFactory
;
import
ui.common.WebDriverFactory
;
import
ui.common.WebDriverType
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Set
;
import
static
com
.
codeborne
.
selenide
.
Selenide
.
$
;
/**
* Created by mabo on 2018/11/20
*/
public
class
DuibaBaseUi
extends
DuibaBase
{
RemoteWebDriver
driver
=
WebDriverFactory
.
createWebDriver
(
WebDriverType
.
MOBLIE
,
ProxyFactory
.
createProxy
());
public
ITestResult
result
;
public
void
switchChrome
(){
WebDriverRunner
.
closeWebDriver
();
driver
=
WebDriverFactory
.
createWebDriver
(
WebDriverType
.
CHRMOE
,
ProxyFactory
.
createProxy
());
WebDriverRunner
.
setWebDriver
(
driver
);
}
public
void
switchMobile
(){
WebDriverRunner
.
closeWebDriver
();
driver
=
WebDriverFactory
.
createWebDriver
(
WebDriverType
.
MOBLIE
,
ProxyFactory
.
createProxy
());
WebDriverRunner
.
setWebDriver
(
driver
);
}
@BeforeClass
public
final
void
init
(){
WebDriverRunner
.
setWebDriver
(
driver
);
}
@BeforeMethod
(
alwaysRun
=
true
)
public
final
void
beforeMethodInit
(
ITestResult
result
)
throws
Exception
{
Reporter
.
setCurrentTestResult
(
result
);
this
.
result
=
result
;
}
@AfterMethod
(
alwaysRun
=
true
)
public
final
void
afterMethodScreenshot
()
throws
Exception
{
if
(!
result
.
isSuccess
())
screenshot
();
}
public
final
void
screenshot
()
throws
IOException
{
boolean
ev
=
Boolean
.
parseBoolean
(
System
.
getProperty
(
"Server"
));
String
path
=
null
;
String
url
=
null
;
if
(
ev
){
File
file
=
new
File
(
"C:\\image"
);
path
=
file
.
getAbsolutePath
()+
"\\"
;
url
=
"http://172.16.80.106/"
;
}
else
{
File
file
=
new
File
(
" "
);
path
=
file
.
getAbsolutePath
();
url
=
file
.
getAbsolutePath
();
}
Reporter
.
log
(
"ev:"
+
ev
);
Reporter
.
log
(
"path:"
+
path
);
Reporter
.
log
(
"url:"
+
url
);
Reporter
.
setCurrentTestResult
(
result
);
// Reporter.log(file.getAbsolutePath());
String
time
=
String
.
valueOf
(
System
.
currentTimeMillis
());
Reporter
.
log
(
"<img src='"
+
url
+
result
.
getName
()
+
"_"
+
time
+
".jpg' hight='800' width='600' onclick=\"window.open('"
+
url
+
result
.
getName
()
+
"_"
+
time
+
".jpg"
+
"')\" />"
);
//"http://172.16.80.106"
File
srcFile
=
((
TakesScreenshot
)
driver
).
getScreenshotAs
(
OutputType
.
FILE
);
//执行屏幕截取
FileUtils
.
copyFile
(
srcFile
,
new
File
(
path
+
result
.
getName
()
+
"_"
+
time
+
".jpg"
));
}
@AfterClass
public
final
void
close
(){
WebDriverRunner
.
closeWebDriver
();
}
/**
* 等待
* @param time 秒
*/
public
final
void
sleep
(
int
time
){
try
{
Thread
.
sleep
(
time
*
1000
);
logger
.
info
(
"sleep:"
+
time
);
}
catch
(
InterruptedException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
/**
* 点击通过text(),等于
* @param name
* @throws Exception
*/
public
final
void
clickByTextEqual
(
String
name
)
throws
Exception
{
String
xpath
=
"//*[text()='"
+
name
+
"']"
;
int
i
=
5
;
while
(
i
>
0
){
try
{
$
(
By
.
xpath
(
xpath
)).
click
();
logger
.
info
(
"ByXpath:"
+
xpath
+
" click"
);
return
;
}
catch
(
Exception
e
)
{
// TODO: handle exception
sleep
(
1
);
i
--;
if
(
i
==
0
)
throw
e
;
}
}
}
/**
* 点击通过text(),等于
* @param name
* @throws Exception
*/
public
final
void
clickByClass
(
String
name
)
throws
Exception
{
String
xpath
=
"//*[@class='"
+
name
+
"']"
;
int
i
=
5
;
while
(
i
>
0
){
try
{
driver
.
findElementByXPath
(
xpath
).
click
();
logger
.
info
(
"xpath:"
+
xpath
+
" click"
);
return
;
}
catch
(
Exception
e
)
{
// TODO: handle exception
sleep
(
1
);
i
--;
if
(
i
==
0
)
throw
e
;
}
}
}
/**
* 点击,通过属性,包含
* @param atttibut
* @param name
* @param tag
* @throws Exception
*/
public
void
clickByContainsAttribut
(
String
atttibut
,
String
name
,
String
tag
)
throws
Exception
{
String
xpath
=
"//"
+
tag
+
"[contains(@"
+
atttibut
+
",'"
+
name
+
"')]"
;
int
i
=
3
;
while
(
i
>
0
){
try
{
System
.
out
.
println
(
i
);
driver
.
findElementByXPath
(
xpath
).
click
();
logger
.
info
(
"ByXpath:"
+
xpath
+
" click"
);
return
;
}
catch
(
Exception
e
)
{
// TODO: handle exception
sleep
(
1
);
i
--;
if
(
i
==
0
)
throw
e
;
}
}
}
/**
* 切换窗口
*/
public
void
switchWindow
(){
String
handle
=
null
;
Set
<
String
>
handles
=
driver
.
getWindowHandles
();
for
(
String
hand:
handles
)
handle
=
hand
;
driver
.
switchTo
().
window
(
handle
);
}
}
src/test/java/http/cases/DefinedActivityTest/CustomActivity_DuibaTest.java
View file @
77052a56
...
@@ -95,7 +95,7 @@ public class CustomActivity_DuibaTest extends DuibaTestBase {
...
@@ -95,7 +95,7 @@ public class CustomActivity_DuibaTest extends DuibaTestBase {
String
androidDL
=
MatcherString
.
getString
(
ManagerResponse
.
asString
(),
"androidurl: '(.*?)',"
,
1
);
String
androidDL
=
MatcherString
.
getString
(
ManagerResponse
.
asString
(),
"androidurl: '(.*?)',"
,
1
);
String
iOSDL
=
MatcherString
.
getString
(
ManagerResponse
.
asString
(),
"iosurl: '(.*?)',"
,
1
);
String
iOSDL
=
MatcherString
.
getString
(
ManagerResponse
.
asString
(),
"iosurl: '(.*?)',"
,
1
);
String
usebtn
=
MatcherString
.
getString
(
ManagerResponse
.
asString
(),
"usebtn: '(.*?)',"
,
1
);
String
usebtn
=
MatcherString
.
getString
(
ManagerResponse
.
asString
(),
"usebtn: '(.*?)',"
,
1
);
String
actLinkEx
=
"//activity.m.duibatest.com.cn/crecord/recordDetailNew
/
"
;
String
actLinkEx
=
"//activity.m.duibatest.com.cn/crecord/recordDetailNew"
;
String
linkUrl
=
MatcherString
.
getString
(
LinkResponse
.
asString
(),
"target=\"_blank\" href=\"(.*?)\">"
,
1
);
String
linkUrl
=
MatcherString
.
getString
(
LinkResponse
.
asString
(),
"target=\"_blank\" href=\"(.*?)\">"
,
1
);
//进行接口测试传参
//进行接口测试传参
...
...
src/test/java/http/cases/
SaasDeveloperTest/修改兑吧商品
.java
→
src/test/java/http/cases/
GoodsAndTradeTest/修改兑吧商品_ExchangeTest
.java
View file @
77052a56
package
http
.
cases
.
SaasDeveloper
Test
;
package
http
.
cases
.
GoodsAndTrade
Test
;
import
base.Config
;
import
base.Config
;
import
base.DuibaTestBase
;
import
base.DuibaTestBase
;
...
@@ -15,7 +15,7 @@ import org.testng.annotations.Test;
...
@@ -15,7 +15,7 @@ import org.testng.annotations.Test;
@ContextConfiguration
(
classes
=
Config
.
class
)
@ContextConfiguration
(
classes
=
Config
.
class
)
public
class
修改兑吧商品
extends
DuibaTestBase
{
public
class
修改兑吧商品
_ExchangeTest
extends
DuibaTestBase
{
@Autowired
@Autowired
DoUpdateAppItemService
doUpdateAppItemService
;
DoUpdateAppItemService
doUpdateAppItemService
;
...
...
src/test/java/http/cases/
SaasDeveloperTest/商品管理操作_Duiba
Test.java
→
src/test/java/http/cases/
GoodsAndTradeTest/商品管理操作_Exchange
Test.java
View file @
77052a56
package
http
.
cases
.
SaasDeveloper
Test
;
package
http
.
cases
.
GoodsAndTrade
Test
;
import
base.Config
;
import
base.Config
;
import
utils.PublicMethod
;
import
utils.PublicMethod
;
...
@@ -19,7 +19,7 @@ import org.testng.annotations.Test;
...
@@ -19,7 +19,7 @@ import org.testng.annotations.Test;
*/
*/
@ContextConfiguration
(
classes
=
Config
.
class
)
@ContextConfiguration
(
classes
=
Config
.
class
)
public
class
商品管理操作
_
Duiba
Test
extends
AbstractTestNGSpringContextTests
{
public
class
商品管理操作
_
Exchange
Test
extends
AbstractTestNGSpringContextTests
{
@Autowired
@Autowired
SpglczService
czService
;
SpglczService
czService
;
@Autowired
@Autowired
...
...
src/test/java/http/cases/
SaasDeveloperTest/异常订单测试
.java
→
src/test/java/http/cases/
GoodsAndTradeTest/异常订单测试_ExchangeTest
.java
View file @
77052a56
package
http
.
cases
.
SaasDeveloper
Test
;
package
http
.
cases
.
GoodsAndTrade
Test
;
import
base.Config
;
import
base.Config
;
import
base.DuibaTestBase
;
import
base.DuibaTestBase
;
...
@@ -21,7 +21,7 @@ import java.util.Map;
...
@@ -21,7 +21,7 @@ import java.util.Map;
@ContextConfiguration
(
classes
=
Config
.
class
)
@ContextConfiguration
(
classes
=
Config
.
class
)
public
class
异常订单测试
extends
DuibaTestBase
{
public
class
异常订单测试
_ExchangeTest
extends
DuibaTestBase
{
@Autowired
@Autowired
private
MobileService
mobileService
;
private
MobileService
mobileService
;
...
...
src/test/java/http/cases/
SaasDeveloperTest/自有优惠券测试_Duiba
Test.java
→
src/test/java/http/cases/
GoodsAndTradeTest/自有优惠券测试_Exchange
Test.java
View file @
77052a56
package
http
.
cases
.
SaasDeveloper
Test
;
package
http
.
cases
.
GoodsAndTrade
Test
;
import
base.Config
;
import
base.Config
;
...
@@ -16,7 +16,7 @@ import org.testng.annotations.Test;
...
@@ -16,7 +16,7 @@ import org.testng.annotations.Test;
* 自有优惠券添加、修改、删除、上架或下架、查询操作
* 自有优惠券添加、修改、删除、上架或下架、查询操作
*/
*/
@ContextConfiguration
(
classes
=
Config
.
class
)
@ContextConfiguration
(
classes
=
Config
.
class
)
public
class
自有优惠券测试
_
Duiba
Test
extends
AbstractTestNGSpringContextTests
{
public
class
自有优惠券测试
_
Exchange
Test
extends
AbstractTestNGSpringContextTests
{
@Autowired
@Autowired
DeveloperObjectService
developerObjectService
;
DeveloperObjectService
developerObjectService
;
@Autowired
@Autowired
...
...
src/test/java/http/cases/
SaasDeveloperTest/自有实物测试_Duiba
Test.java
→
src/test/java/http/cases/
GoodsAndTradeTest/自有实物测试_Exchange
Test.java
View file @
77052a56
package
http
.
cases
.
SaasDeveloper
Test
;
package
http
.
cases
.
GoodsAndTrade
Test
;
import
base.Config
;
import
base.Config
;
import
utils.PublicMethod
;
import
utils.PublicMethod
;
...
@@ -17,7 +17,7 @@ import org.testng.annotations.Test;
...
@@ -17,7 +17,7 @@ import org.testng.annotations.Test;
* @author wangxiaoshuang
* @author wangxiaoshuang
*/
*/
@ContextConfiguration
(
classes
=
Config
.
class
)
@ContextConfiguration
(
classes
=
Config
.
class
)
public
class
自有实物测试
_
Duiba
Test
extends
AbstractTestNGSpringContextTests
{
public
class
自有实物测试
_
Exchange
Test
extends
AbstractTestNGSpringContextTests
{
@Autowired
@Autowired
DeveloperObjectService
objectService
;
DeveloperObjectService
objectService
;
...
...
src/test/java/http/cases/
SaasDeveloperTest/自有虚拟商品测试_Duiba
Test.java
→
src/test/java/http/cases/
GoodsAndTradeTest/自有虚拟商品测试_Exchange
Test.java
View file @
77052a56
package
http
.
cases
.
SaasDeveloper
Test
;
package
http
.
cases
.
GoodsAndTrade
Test
;
import
base.Config
;
import
base.Config
;
import
utils.PublicMethod
;
import
utils.PublicMethod
;
...
@@ -15,7 +15,7 @@ import org.testng.annotations.Test;
...
@@ -15,7 +15,7 @@ import org.testng.annotations.Test;
* 自有虚拟商品添加、修改、删除、上架或下架、查询操作
* 自有虚拟商品添加、修改、删除、上架或下架、查询操作
*/
*/
@ContextConfiguration
(
classes
=
Config
.
class
)
@ContextConfiguration
(
classes
=
Config
.
class
)
public
class
自有虚拟商品测试
_
Duiba
Test
extends
AbstractTestNGSpringContextTests
{
public
class
自有虚拟商品测试
_
Exchange
Test
extends
AbstractTestNGSpringContextTests
{
@Autowired
@Autowired
DeveloperVirtualService
developerVirtualService
;
DeveloperVirtualService
developerVirtualService
;
@Autowired
@Autowired
...
...
src/test/java/http/cases/NewActivityTest/优惠券测试_DuibaTest.java
View file @
77052a56
...
@@ -54,7 +54,7 @@ public class 优惠券测试_DuibaTest extends AbstractTestNGSpringContextTests
...
@@ -54,7 +54,7 @@ public class 优惠券测试_DuibaTest extends AbstractTestNGSpringContextTests
String
androidDL
=
MatcherString
.
getString
(
ManagerResponse
.
asString
(),
"androidurl: '(.*?)',"
,
1
);
String
androidDL
=
MatcherString
.
getString
(
ManagerResponse
.
asString
(),
"androidurl: '(.*?)',"
,
1
);
String
iOSDL
=
MatcherString
.
getString
(
ManagerResponse
.
asString
(),
"iosurl: '(.*?)',"
,
1
);
String
iOSDL
=
MatcherString
.
getString
(
ManagerResponse
.
asString
(),
"iosurl: '(.*?)',"
,
1
);
String
actusebtn
=
MatcherString
.
getString
(
ManagerResponse
.
asString
(),
"usebtn: '(.*?)',"
,
1
);
String
actusebtn
=
MatcherString
.
getString
(
ManagerResponse
.
asString
(),
"usebtn: '(.*?)',"
,
1
);
String
actLinkEx
=
"//activity.m.duibatest.com.cn/crecord/recordDetailNew
/
"
;
String
actLinkEx
=
"//activity.m.duibatest.com.cn/crecord/recordDetailNew"
;
String
linkUrl
=
MatcherString
.
getString
(
LinkResponse
.
asString
(),
"target=\"_blank\" href=\"(.*?)\">"
,
1
);
String
linkUrl
=
MatcherString
.
getString
(
LinkResponse
.
asString
(),
"target=\"_blank\" href=\"(.*?)\">"
,
1
);
//获取管理员后台优惠券库存
//获取管理员后台优惠券库存
...
...
src/test/java/http/cases/NewActivityTest/谢谢参与测试_DuibaTest.java
View file @
77052a56
...
@@ -32,6 +32,7 @@ public class 谢谢参与测试_DuibaTest extends DuibaTestBase {
...
@@ -32,6 +32,7 @@ public class 谢谢参与测试_DuibaTest extends DuibaTestBase {
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"lottery.type"
),
"thanks"
,
"校验类型失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"lottery.type"
),
"thanks"
,
"校验类型失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"lottery.id"
).
isEmpty
(),
false
,
"校验id失败"
);
Assert
.
assertEquals
(
response
.
jsonPath
().
getString
(
"lottery.id"
).
isEmpty
(),
false
,
"校验id失败"
);
Assert
.
assertNotNull
(
response
.
jsonPath
().
getString
(
"lottery.id"
),
"校验id失败"
);
//校验返回字段
//校验返回字段
Assert
.
assertEquals
(
response
.
asString
().
contains
(
"id"
),
true
,
"校验id失败"
);
Assert
.
assertEquals
(
response
.
asString
().
contains
(
"id"
),
true
,
"校验id失败"
);
logger
.
info
(
"校验type,id成功"
);
logger
.
info
(
"校验type,id成功"
);
...
...
src/test/java/http/cases/PkTest/pk_开奖_瓜分红包测试.java
View file @
77052a56
...
@@ -74,6 +74,7 @@ public class pk_开奖_瓜分红包测试 extends DuibaTestBase {
...
@@ -74,6 +74,7 @@ public class pk_开奖_瓜分红包测试 extends DuibaTestBase {
//注意初始化的方法不能与父类的相同,会被覆盖住
//注意初始化的方法不能与父类的相同,会被覆盖住
public
void
setUpPkActivity
()
{
public
void
setUpPkActivity
()
{
try
{
try
{
createPk
(
"2"
,
"2020-08-12 00:00:00"
,
groupId
);
createPk
(
"2"
,
"2020-08-12 00:00:00"
,
groupId
);
}
catch
(
Exception
e
){
}
catch
(
Exception
e
){
...
...
src/test/java/http/cases/S
aasDeveloperTest/签到管理_Duiba
Test.java
→
src/test/java/http/cases/S
ignTest/开发者签到管理_sign
Test.java
View file @
77052a56
package
http
.
cases
.
S
aasDeveloper
Test
;
package
http
.
cases
.
S
ign
Test
;
import
base.Config
;
import
base.Config
;
import
http.service.Saas.SignService
;
import
http.service.Saas.SignService
;
...
@@ -16,7 +16,7 @@ import org.testng.annotations.Test;
...
@@ -16,7 +16,7 @@ import org.testng.annotations.Test;
@ContextConfiguration
(
classes
=
Config
.
class
)
@ContextConfiguration
(
classes
=
Config
.
class
)
public
class
签到管理
_Duiba
Test
extends
AbstractTestNGSpringContextTests
{
public
class
开发者签到管理
_sign
Test
extends
AbstractTestNGSpringContextTests
{
@Autowired
@Autowired
SignService
signService
;
SignService
signService
;
...
...
src/test/java/http/cases/WalletTest/种红包配置校验_AccessTest.java
View file @
77052a56
...
@@ -30,9 +30,10 @@ public class 种红包配置校验_AccessTest extends DuibaTestBase{
...
@@ -30,9 +30,10 @@ public class 种红包配置校验_AccessTest extends DuibaTestBase{
//指定用户
//指定用户
private
static
int
uid
=
4689
;
private
static
int
uid
=
4689
;
private
static
int
uid2
=
4552
;
private
static
int
uid2
=
4552
;
private
static
int
uid3
=
3590
;
private
static
int
uid4
=
4386
;
@Test
@Test
public
void
出券开关校验
_
开
()
throws
Exception
{
public
void
出券
衰减
开关校验
_
开
()
throws
Exception
{
//dafuweng登陆获取cookies
//dafuweng登陆获取cookies
Map
cookies
=
authorization
.
dafuwengLogin
(
uid
);
Map
cookies
=
authorization
.
dafuwengLogin
(
uid
);
//校验种红包配置
//校验种红包配置
...
@@ -58,11 +59,12 @@ public class 种红包配置校验_AccessTest extends DuibaTestBase{
...
@@ -58,11 +59,12 @@ public class 种红包配置校验_AccessTest extends DuibaTestBase{
logger
.
info
(
"种红包的红包配置接口校验正确"
);
logger
.
info
(
"种红包的红包配置接口校验正确"
);
}
}
@Test
@Test
public
void
出券开关校验
_
关
()
throws
Exception
{
public
void
出券
衰减
开关校验
_
关
()
throws
Exception
{
//dafuweng登陆获取cookies
//dafuweng登陆获取cookies
Map
cookies
=
authorization
.
dafuwengLogin
(
uid2
);
Map
cookies
=
authorization
.
dafuwengLogin
(
uid2
);
//校验种红包配置
//校验种红包配置
...
@@ -81,4 +83,53 @@ public class 种红包配置校验_AccessTest extends DuibaTestBase{
...
@@ -81,4 +83,53 @@ public class 种红包配置校验_AccessTest extends DuibaTestBase{
logger
.
info
(
"种红包的红包配置接口校验正确"
);
logger
.
info
(
"种红包的红包配置接口校验正确"
);
}
}
@Test
public
void
流量策略打开校验
()
throws
Exception
{
//dafuweng登陆获取cookies
Map
cookies
=
authorization
.
dafuwengLogin
(
uid3
);
//校验种红包配置
Response
response
=
seedRedPacketService
.
getExtConfig
(
cookies
);
response
.
prettyPrint
();
String
adPositions
=
response
.
jsonPath
().
getString
(
"data.adPositions"
);
String
adSwitch
=
response
.
jsonPath
().
getString
(
"data.adSwitch"
);
String
decrBeginTime
=
response
.
jsonPath
().
getString
(
"data.decrBeginTime"
);
String
decrSwitch
=
response
.
jsonPath
().
getString
(
"data.decrSwitch"
);
Assert
.
assertNull
(
adPositions
,
"发券位置校验异常"
);
Assert
.
assertEquals
(
adSwitch
,
"false"
,
"种红包开关校验异常"
);
Assert
.
assertEquals
(
decrSwitch
,
"false"
,
"种红包衰减开关校验异常"
);
Assert
.
assertNull
(
decrBeginTime
,
"衰减时间校验异常"
);
logger
.
info
(
"种红包的红包配置接口校验正确"
);
}
@Test
public
void
衰减红包校验
()
throws
Exception
{
//dafuweng登陆获取cookies
Map
cookies
=
authorization
.
dafuwengLogin
(
uid4
);
//调用种植seed
Response
response
=
seedRedPacketService
.
seed
(
cookies
,
"1"
,
"424"
,
"1"
);
//种子号
String
orderId
=
response
.
jsonPath
().
getString
(
"data.orderNum"
);
Assert
.
assertNotNull
(
orderId
,
"订单号为空"
);
logger
.
info
(
"红包订单为:"
+
orderId
);
//红包衰减
Thread
.
sleep
(
65000
);
//获取种植结果状态getOrderStatus,异步接口,while循环,status为2处理完成,1处理中
response
=
seedRedPacketService
.
getOrderStatus
(
cookies
,
orderId
);
String
status
=
response
.
jsonPath
().
getString
(
"data"
);
int
i
=
5
;
while
(
i
>
0
&&
status
.
equals
(
"1"
)){
response
=
seedRedPacketService
.
getOrderStatus
(
cookies
,
orderId
);
status
=
response
.
jsonPath
().
getString
(
"data"
);
i
--;
}
//获取种植获得金额
response
=
seedRedPacketService
.
reap
(
cookies
,
"1"
,
orderId
);
response
.
prettyPrint
();
String
isDecr
=
response
.
jsonPath
().
getString
(
"data.isDecr"
);
Assert
.
assertEquals
(
isDecr
,
"true"
,
"红包衰减标识校验失败"
);
}
}
}
src/test/java/ui/cases/Exchange/优惠券_ExchangeTest_ui.java
0 → 100644
View file @
77052a56
package
ui
.
cases
.
Exchange
;
import
base.DuibaBaseUi
;
import
org.openqa.selenium.By
;
import
org.testng.annotations.Test
;
import
static
com
.
codeborne
.
selenide
.
Selenide
.
$
;
import
static
com
.
codeborne
.
selenide
.
Selenide
.
open
;
/**
* Created by mabo on 2018/11/21
*/
public
class
优惠券
_ExchangeTest_ui
extends
DuibaBaseUi
{
@Test
public
void
优惠券兑换
_
正常流程
()
throws
Exception
{
open
(
"http://47.97.214.108/user/index"
);
clickByTextEqual
(
"4762"
);
switchWindow
();
sleep
(
2
);
clickByClass
(
"btn-close"
);
screenshot
();
clickByTextEqual
(
"ui自动化-优惠券"
);
screenshot
();
clickByTextEqual
(
"马上兑换"
);
screenshot
();
clickByTextEqual
(
"确定"
);
screenshot
();
sleep
(
5
);
screenshot
();
}
}
src/test/java/ui/cases/Exchange/实物_ExchangeTest_ui.java
0 → 100644
View file @
77052a56
package
ui
.
cases
.
Exchange
;
import
base.DuibaBaseUi
;
import
org.testng.annotations.Test
;
import
static
com
.
codeborne
.
selenide
.
Selenide
.
open
;
/**
* Created by mabo on 2018/11/22
*/
public
class
实物
_ExchangeTest_ui
extends
DuibaBaseUi
{
@Test
public
void
实物兑换
_
正常流程
()
throws
Exception
{
open
(
"http://47.97.214.108/user/index"
);
clickByTextEqual
(
"4762"
);
switchWindow
();
sleep
(
2
);
clickByClass
(
"btn-close"
);
screenshot
();
clickByTextEqual
(
"ui自动化-实物"
);
screenshot
();
clickByTextEqual
(
"马上兑换"
);
screenshot
();
clickByTextEqual
(
"确定"
);
screenshot
();
sleep
(
5
);
screenshot
();
}
}
src/test/java/ui/cases/Exchange/支付宝_ExchangeTest_ui.java
0 → 100644
View file @
77052a56
package
ui
.
cases
.
Exchange
;
import
base.DuibaBaseUi
;
import
org.testng.annotations.Test
;
import
static
com
.
codeborne
.
selenide
.
Selenide
.
open
;
/**
* Created by mabo on 2018/11/22
*/
public
class
支付宝
_ExchangeTest_ui
extends
DuibaBaseUi
{
@Test
public
void
支付宝
_
正常流程
()
throws
Exception
{
open
(
"http://47.97.214.108/user/index"
);
clickByTextEqual
(
"4762"
);
switchWindow
();
sleep
(
2
);
clickByClass
(
"btn-close"
);
screenshot
();
clickByTextEqual
(
"支付宝充值"
);
screenshot
();
clickByTextEqual
(
"马上兑换"
);
screenshot
();
clickByTextEqual
(
"确定"
);
screenshot
();
sleep
(
5
);
screenshot
();
}
}
src/test/java/ui/cases/test.java
View file @
77052a56
package
ui
.
cases
;
package
ui
.
cases
;
import
base.DuibaBaseUi
;
import
base.DuibaLog
;
import
base.DuibaLog
;
import
com.codeborne.selenide.WebDriverRunner
;
import
com.codeborne.selenide.WebDriverRunner
;
import
com.codeborne.selenide.testng.ScreenShooter
;
import
com.codeborne.selenide.testng.ScreenShooter
;
...
@@ -32,9 +33,9 @@ import static com.codeborne.selenide.Selenide.open;
...
@@ -32,9 +33,9 @@ import static com.codeborne.selenide.Selenide.open;
* Created by mabo on 2018/10/18
* Created by mabo on 2018/10/18
*/
*/
//@Listeners({ ScreenShooter.class})
//@Listeners({ ScreenShooter.class})
public
class
test
{
public
class
test
extends
DuibaBaseUi
{
// StatusCheckor checkor=new StatusCheckor();
// StatusCheckor checkor=new StatusCheckor();
WebDriver
driver
=
WebDriverFactory
.
createWebDriver
(
WebDriverType
.
CHRMOE
,
ProxyFactory
.
createProxy
());
//
WebDriver driver= WebDriverFactory.createWebDriver(WebDriverType.CHRMOE, ProxyFactory.createProxy());
@Test
@Test
...
@@ -42,10 +43,14 @@ public class test {
...
@@ -42,10 +43,14 @@ public class test {
ScreenShooter
.
captureSuccessfulTests
=
true
;
ScreenShooter
.
captureSuccessfulTests
=
true
;
//StatusCheckor checkor=new StatusCheckor();
//StatusCheckor checkor=new StatusCheckor();
// ProxyFactory.addCheckor(checkor);
// ProxyFactory.addCheckor(checkor);
WebDriverRunner
.
setWebDriver
(
driver
);
//
WebDriverRunner.setWebDriver(driver);
open
(
"https://www.baidu.com"
);
open
(
"https://www.baidu.com"
);
Reporter
.
log
(
"----------------------"
);
screenshot
();
Reporter
.
log
(
"----------------------"
);
$
(
By
.
id
(
"kw"
)).
setValue
(
"selenium"
);
$
(
By
.
id
(
"kw"
)).
setValue
(
"selenium"
);
Assert
.
assertEquals
(
1
,
2
);
Assert
.
assertEquals
(
1
,
2
);
...
@@ -58,7 +63,7 @@ public class test {
...
@@ -58,7 +63,7 @@ public class test {
}
}
@Test
@Test
public
void
test1
(){
public
void
test1
(){
Reporter
.
log
(
"rererfddfdfdfdfdfdf
"
);
open
(
"https://www.biying.com
"
);
Reporter
.
log
(
"rererfddfdfdfdfdfdf"
);
Reporter
.
log
(
"rererfddfdfdfdfdfdf"
);
Reporter
.
log
(
"rererfddfdfdfdfdfdf"
);
Reporter
.
log
(
"rererfddfdfdfdfdfdf"
);
Reporter
.
log
(
"rererfddfdfdfdfdfdf"
);
Reporter
.
log
(
"rererfddfdfdfdfdfdf"
);
...
@@ -79,25 +84,25 @@ public class test {
...
@@ -79,25 +84,25 @@ public class test {
}
}
@AfterMethod
(
alwaysRun
=
true
)
//
@AfterMethod(alwaysRun = true)
public
void
afterMethod
(
ITestResult
result
)
throws
Exception
{
//
public void afterMethod(ITestResult result) throws Exception {
if
(!
result
.
isSuccess
())
//
if (!result.isSuccess())
catchExceptions
(
result
);
//
catchExceptions(result);
}
//
}
public
void
catchExceptions
(
ITestResult
result
)
throws
IOException
{
//
public void catchExceptions(ITestResult result) throws IOException {
File
file
=
new
File
(
"C:/image"
);
//
File file = new File("C:/image");
Reporter
.
setCurrentTestResult
(
result
);
//
Reporter.setCurrentTestResult(result);
Reporter
.
log
(
file
.
getAbsolutePath
());
//
Reporter.log(file.getAbsolutePath());
String
time
=
String
.
valueOf
(
System
.
currentTimeMillis
());
//
String time = String.valueOf(System.currentTimeMillis());
Reporter
.
log
(
"<img src='"
+
"http://172.16.80.106"
+
"/"
+
result
.
getName
()
+
"_"
+
time
+
".jpg' hight='600' width='600'/>"
);
//
Reporter.log("<img src='" + "http://172.16.80.106" + "/" + result.getName() +"_"+time+ ".jpg' hight='600' width='600'/>");
File
srcFile
=
((
TakesScreenshot
)
driver
).
getScreenshotAs
(
OutputType
.
FILE
);
//执行屏幕截取
//
File srcFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); //执行屏幕截取
FileUtils
.
copyFile
(
srcFile
,
new
File
(
file
.
getAbsolutePath
()
+
"/"
+
result
.
getName
()
+
"_"
+
time
+
".jpg"
));
//
FileUtils.copyFile(srcFile, new File(file.getAbsolutePath() + "/" + result.getName() +"_"+time+ ".jpg"));
//
}
//
}
//
public
static
void
main
(
String
[]
args
)
{
//
public static void main(String[] args) {
System
.
out
.
println
(
System
.
currentTimeMillis
());
//
System.out.println(System.currentTimeMillis());
System
.
out
.
println
(
Calendar
.
getInstance
().
getTimeInMillis
());
//
System.out.println(Calendar.getInstance().getTimeInMillis());
System
.
out
.
println
(
new
Date
().
getTime
());
//
System.out.println(new Date().getTime());
}
//
}
}
}
src/test/java/ui/cases/uitest.java
0 → 100644
View file @
77052a56
package
ui
.
cases
;
import
base.DuibaBaseUi
;
import
com.codeborne.selenide.testng.ScreenShooter
;
import
org.openqa.selenium.By
;
import
org.testng.Assert
;
import
org.testng.annotations.Test
;
import
java.io.IOException
;
import
static
com
.
codeborne
.
selenide
.
Selenide
.
$
;
import
static
com
.
codeborne
.
selenide
.
Selenide
.
open
;
/**
* Created by mabo on 2018/11/21
*/
public
class
uitest
extends
DuibaBaseUi
{
@Test
public
void
中文
1
()
throws
IOException
{
ScreenShooter
.
captureSuccessfulTests
=
true
;
//StatusCheckor checkor=new StatusCheckor();
// ProxyFactory.addCheckor(checkor);
// WebDriverRunner.setWebDriver(driver);
open
(
"https://www.biying.com"
);
$
(
By
.
id
(
"kw"
)).
setValue
(
"selenium"
);
Assert
.
assertEquals
(
1
,
2
);
// SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss"); //转换时间格式
// String time = dateFormat.format(Calendar.getInstance().getTime()); //获取当前时间
}
}
src/test/java/ui/common/WebDriverFactory.java
View file @
77052a56
...
@@ -3,14 +3,18 @@ package ui.common;
...
@@ -3,14 +3,18 @@ package ui.common;
import
org.openqa.selenium.Proxy
;
import
org.openqa.selenium.Proxy
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.WebDriver
;
import
org.openqa.selenium.chrome.ChromeDriver
;
import
org.openqa.selenium.chrome.ChromeDriver
;
import
org.openqa.selenium.chrome.ChromeOptions
;
import
org.openqa.selenium.firefox.FirefoxDriver
;
import
org.openqa.selenium.firefox.FirefoxDriver
;
import
org.openqa.selenium.logging.LogType
;
import
org.openqa.selenium.logging.LogType
;
import
org.openqa.selenium.logging.LoggingPreferences
;
import
org.openqa.selenium.logging.LoggingPreferences
;
import
org.openqa.selenium.remote.CapabilityType
;
import
org.openqa.selenium.remote.CapabilityType
;
import
org.openqa.selenium.remote.DesiredCapabilities
;
import
org.openqa.selenium.remote.DesiredCapabilities
;
import
org.openqa.selenium.remote.RemoteWebDriver
;
import
org.openqa.selenium.safari.SafariDriver
;
import
org.openqa.selenium.safari.SafariDriver
;
import
java.io.File
;
import
java.io.File
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Properties
;
import
java.util.Properties
;
import
java.util.logging.Level
;
import
java.util.logging.Level
;
...
@@ -49,23 +53,25 @@ public class WebDriverFactory {
...
@@ -49,23 +53,25 @@ public class WebDriverFactory {
}
}
return
browser
;
return
browser
;
}
}
public
static
WebDriver
createWebDriver
(
WebDriverType
driverType
,
Proxy
proxy
){
public
static
RemoteWebDriver
createWebDriver
(
WebDriverType
driverType
,
Proxy
proxy
){
// configure it as a desired capability
DesiredCapabilities
capabilities
=
new
DesiredCapabilities
();
DesiredCapabilities
capabilities
=
new
DesiredCapabilities
();
//capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS,true);
// capabilities.setCapability(CapabilityType.PROXY, proxy);
capabilities
.
setCapability
(
CapabilityType
.
PROXY
,
proxy
);
LoggingPreferences
logPrefs
=
new
LoggingPreferences
();
LoggingPreferences
logPrefs
=
new
LoggingPreferences
();
logPrefs
.
enable
(
LogType
.
BROWSER
,
Level
.
ALL
);
logPrefs
.
enable
(
LogType
.
BROWSER
,
Level
.
ALL
);
capabilities
.
setCapability
(
CapabilityType
.
LOGGING_PREFS
,
logPrefs
);
capabilities
.
setCapability
(
CapabilityType
.
LOGGING_PREFS
,
logPrefs
);
capabilities
.
setCapability
(
CapabilityType
.
SUPPORTS_APPLICATION_CACHE
,
false
);
capabilities
.
setCapability
(
CapabilityType
.
SUPPORTS_APPLICATION_CACHE
,
false
);
capabilities
.
setCapability
(
CapabilityType
.
SUPPORTS_LOCATION_CONTEXT
,
false
);
capabilities
.
setCapability
(
CapabilityType
.
SUPPORTS_LOCATION_CONTEXT
,
false
);
capabilities
.
setCapability
(
CapabilityType
.
SUPPORTS_WEB_STORAGE
,
false
);
capabilities
.
setCapability
(
CapabilityType
.
SUPPORTS_WEB_STORAGE
,
false
);
final
ChromeOptions
chromeOptions
=
new
ChromeOptions
();
Map
<
String
,
String
>
mobileEmulation
=
new
HashMap
<
String
,
String
>();
mobileEmulation
.
put
(
"deviceName"
,
"Nexus 5"
);
chromeOptions
.
setExperimentalOption
(
"mobileEmulation"
,
mobileEmulation
);
Properties
prop
=
System
.
getProperties
();
Properties
prop
=
System
.
getProperties
();
String
OS
=
prop
.
getProperty
(
"os.name"
);
String
OS
=
prop
.
getProperty
(
"os.name"
);
boolean
bl
=
OS
.
startsWith
(
"Mac"
);
boolean
bl
=
OS
.
startsWith
(
"Mac"
);
String
basePath
=
WebDriverType
.
class
.
getClassLoader
().
getResource
(
""
).
getPath
();
String
basePath
=
WebDriverType
.
class
.
getClassLoader
().
getResource
(
""
).
getPath
();
WebDriver
browser
=
null
;
Remote
WebDriver
browser
=
null
;
String
driverPath
=
null
;
String
driverPath
=
null
;
switch
(
driverType
){
switch
(
driverType
){
case
CHRMOE:
case
CHRMOE:
...
@@ -81,6 +87,18 @@ public class WebDriverFactory {
...
@@ -81,6 +87,18 @@ public class WebDriverFactory {
browser
=
new
ChromeDriver
(
capabilities
);
browser
=
new
ChromeDriver
(
capabilities
);
break
;
break
;
case
MOBLIE:
if
(
bl
){
driverPath
=
basePath
+
"chromedriver"
;
}
else
{
driverPath
=
basePath
+
"chromedriver.exe"
;
}
System
.
setProperty
(
"webdriver.chrome.driver"
,
driverPath
);
//add x
new
File
(
driverPath
).
setExecutable
(
true
);
browser
=
new
ChromeDriver
(
chromeOptions
);
break
;
case
FIREFOX:
case
FIREFOX:
browser
=
new
FirefoxDriver
(
capabilities
);
browser
=
new
FirefoxDriver
(
capabilities
);
break
;
break
;
...
...
src/test/java/ui/common/WebDriverType.java
View file @
77052a56
...
@@ -4,5 +4,5 @@ package ui.common;
...
@@ -4,5 +4,5 @@ package ui.common;
* Created by mabo on 2018/11/13
* Created by mabo on 2018/11/13
*/
*/
public
enum
WebDriverType
{
public
enum
WebDriverType
{
CHRMOE
,
FIREFOX
,
SAFARI
;
CHRMOE
,
FIREFOX
,
SAFARI
,
MOBLIE
;
}
}
src/test/profiles/aliyun/duiba.properties
View file @
77052a56
...
@@ -24,7 +24,7 @@ trade.host = activity.m.duibatest.com.cn
...
@@ -24,7 +24,7 @@ trade.host = activity.m.duibatest.com.cn
//\u6570\u636E\u5E93\u914D\u7F6E
//\u6570\u636E\u5E93\u914D\u7F6E
db.name
=
duiba_test
db.name
=
duiba_test
db.password
=
svbP3KUw2PurAnBb2rbs3vohF
db.password
=
svbP3KUw2PurAnBb2rbs3vohF
db.url
=
jdbc:mysql://rdswy2b9wy53044250u1o.mysql.rds.aliyuncs.com:3306/
db.url
=
jdbc:mysql://rdswy2b9wy53044250u1o.mysql.rds.aliyuncs.com:3306/
?tinyInt1isBit=false
db.driver
=
com.mysql.cj.jdbc.Driver
db.driver
=
com.mysql.cj.jdbc.Driver
db.maxtotal
=
6
db.maxtotal
=
6
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment