Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
Kivii.Test.WebDriver
Project
Overview
Details
Activity
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
示例代码
Kivii.Test.WebDriver
Commits
42609465
Commit
42609465
authored
Nov 09, 2023
by
施晓雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新代码示例
parent
b6fef2b9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
45 additions
and
28 deletions
+45
-28
MyAction.cs
Actions/MyAction.cs
+2
-2
FrmMain.Designer.cs
FrmMain.Designer.cs
+0
-0
FrmMain.cs
FrmMain.cs
+0
-0
Kivii.Test.WebDriver.csproj
Kivii.Test.WebDriver.csproj
+3
-2
MouseTest.cs
Tests/MouseTest.cs
+12
-12
ReferenceTest.cs
Tests/ReferenceTest.cs
+16
-0
WeatherTest.cs
Tests/WeatherTest.cs
+11
-11
packages.config
packages.config
+1
-1
No files found.
Actions/MyAction.cs
View file @
42609465
...
...
@@ -12,11 +12,11 @@ namespace Kivii.Test.WebDriver
internal
class
MyJsAction
:
ActionBase
{
public
string
Js
{
get
;
set
;
}
public
override
string
Execute
(
Manager
manager
)
public
override
string
Execute
(
Window
window
)
{
try
{
var
value
=
manager
.
ExecuteScript
(
Js
);
var
value
=
window
.
ExecuteScript
(
Js
);
return
value
;
}
catch
(
Exception
ex
)
...
...
FrmMain.Designer.cs
View file @
42609465
This diff is collapsed.
Click to expand it.
FrmMain.cs
View file @
42609465
This diff is collapsed.
Click to expand it.
Kivii.Test.WebDriver.csproj
View file @
42609465
...
...
@@ -35,8 +35,8 @@
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"Kivii.WebDriver.V4.7, Version=4.15.2023.110
3
0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
packages\Kivii.WebDriver.4.15.2023.110
3
0\lib\net47\Kivii.WebDriver.V4.7.dll
</HintPath>
<Reference
Include=
"Kivii.WebDriver.V4.7, Version=4.15.2023.110
4
0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
packages\Kivii.WebDriver.4.15.2023.110
4
0\lib\net47\Kivii.WebDriver.V4.7.dll
</HintPath>
</Reference>
<Reference
Include=
"Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"
>
<HintPath>
packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll
</HintPath>
...
...
@@ -69,6 +69,7 @@
<Compile
Include=
"Program.cs"
/>
<Compile
Include=
"Properties\AssemblyInfo.cs"
/>
<Compile
Include=
"Tests\MouseTest.cs"
/>
<Compile
Include=
"Tests\ReferenceTest.cs"
/>
<Compile
Include=
"Tests\WeatherTest.cs"
/>
<EmbeddedResource
Include=
"FrmMain.resx"
>
<DependentUpon>
FrmMain.cs
</DependentUpon>
...
...
Tests/MouseTest.cs
View file @
42609465
...
...
@@ -10,9 +10,9 @@ namespace Kivii.Test.WebDriver.Tests
{
internal
class
MouseTest
{
public
static
W
ebPage
Get
()
public
static
W
indow
Get
()
{
var
rtns
=
new
W
ebPage
(
null
);
var
rtns
=
new
W
indow
(
null
);
//rtns.Url = "https://www.baidu.com";//这个配置可通过NavigateAction进行
...
...
@@ -21,7 +21,7 @@ namespace Kivii.Test.WebDriver.Tests
var
action
=
new
NavigateAction
();
action
.
Name
=
"跳转网站"
;
action
.
Url
=
"http://www.cacs.mofcom.gov.cn/cacscms/view/notice/zhtbomrasff#"
;
rtns
.
A
ctions
.
Add
(
action
);
rtns
.
A
ddAction
(
action
);
}
#
endregion
...
...
@@ -30,7 +30,7 @@ namespace Kivii.Test.WebDriver.Tests
var
action
=
new
MouseAction
();
action
.
Type
=
MouseActionType
.
Pause
;
action
.
DurationMilliseconds
=
2000
;
rtns
.
A
ctions
.
Add
(
action
);
rtns
.
A
ddAction
(
action
);
}
#
endregion
...
...
@@ -39,7 +39,7 @@ namespace Kivii.Test.WebDriver.Tests
var
action
=
new
MouseAction
();
action
.
Type
=
MouseActionType
.
Click
;
action
.
Target
=
new
ElementFinder
(
"//*[@id=\"zhtbomrasff\"]"
);
rtns
.
A
ctions
.
Add
(
action
);
rtns
.
A
ddAction
(
action
);
}
#
endregion
...
...
@@ -48,7 +48,7 @@ namespace Kivii.Test.WebDriver.Tests
var
action
=
new
MouseAction
();
action
.
Type
=
MouseActionType
.
Pause
;
action
.
DurationMilliseconds
=
2000
;
rtns
.
A
ctions
.
Add
(
action
);
rtns
.
A
ddAction
(
action
);
}
#
endregion
...
...
@@ -57,7 +57,7 @@ namespace Kivii.Test.WebDriver.Tests
var
action
=
new
MouseAction
();
action
.
Type
=
MouseActionType
.
Click
;
action
.
Target
=
new
ElementFinder
(
"//*[@id=\"zhtbomrapex\"]"
);
rtns
.
A
ctions
.
Add
(
action
);
rtns
.
A
ddAction
(
action
);
}
#
endregion
...
...
@@ -66,7 +66,7 @@ namespace Kivii.Test.WebDriver.Tests
var
action
=
new
MouseAction
();
action
.
Type
=
MouseActionType
.
Pause
;
action
.
DurationMilliseconds
=
2000
;
rtns
.
A
ctions
.
Add
(
action
);
rtns
.
A
ddAction
(
action
);
}
#
endregion
...
...
@@ -75,7 +75,7 @@ namespace Kivii.Test.WebDriver.Tests
var
action
=
new
MouseAction
();
action
.
Type
=
MouseActionType
.
Click
;
action
.
Target
=
new
ElementFinder
(
"//*[@id=\"zhtbmg\"]"
);
rtns
.
A
ctions
.
Add
(
action
);
rtns
.
A
ddAction
(
action
);
}
#
endregion
...
...
@@ -84,7 +84,7 @@ namespace Kivii.Test.WebDriver.Tests
var
action
=
new
MouseAction
();
action
.
Type
=
MouseActionType
.
Pause
;
action
.
DurationMilliseconds
=
2000
;
rtns
.
A
ctions
.
Add
(
action
);
rtns
.
A
ddAction
(
action
);
}
#
endregion
...
...
@@ -93,7 +93,7 @@ namespace Kivii.Test.WebDriver.Tests
var
action
=
new
MouseAction
();
action
.
Type
=
MouseActionType
.
Click
;
action
.
Target
=
new
ElementFinder
(
"//*[@id=\"zhtbomrasff\"]"
);
rtns
.
A
ctions
.
Add
(
action
);
rtns
.
A
ddAction
(
action
);
}
#
endregion
...
...
@@ -101,7 +101,7 @@ namespace Kivii.Test.WebDriver.Tests
{
var
action
=
new
MouseAction
();
action
.
Type
=
MouseActionType
.
Perform
;
rtns
.
A
ctions
.
Add
(
action
);
rtns
.
A
ddAction
(
action
);
}
#
endregion
return
rtns
;
...
...
Tests/ReferenceTest.cs
0 → 100644
View file @
42609465
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
namespace
Kivii.Test.WebDriver.Tests
{
/// <summary>
/// 本对象是通过manager.SetReference()的方法注入到Manager中
/// 在Manager的ExecuteScript时,就可以使用到本类的内置方法
/// </summary>
internal
class
ReferenceTest
{
}
}
Tests/WeatherTest.cs
View file @
42609465
...
...
@@ -10,17 +10,17 @@ namespace Kivii.Test.WebDriver.Tests
{
internal
class
WeatherTest
{
public
static
W
ebPage
Get
()
public
static
W
indow
Get
()
{
var
rtns
=
new
W
ebPage
(
null
);
var
rtns
=
new
W
indow
(
null
);
//autoPage.Url = "https://www.baidu.com";//生成DEMO时不需要
#
region
第一步,在输入框内输入内容
{
var
action
=
new
InputAction
();
action
.
Name
=
"输入查询内容"
;
action
.
InputValue
=
"最近天气"
;
action
.
ElementFinder
=
new
ElementFinder
(
"kw"
,
"id"
);
rtns
.
A
ctions
.
Add
(
action
);
action
.
Target
=
new
ElementFinder
(
"kw"
,
"id"
);
rtns
.
A
ddAction
(
action
);
}
#
endregion
...
...
@@ -28,8 +28,8 @@ namespace Kivii.Test.WebDriver.Tests
{
var
action
=
new
ClickAction
();
action
.
Name
=
"百度一下"
;
action
.
ElementFinder
=
new
ElementFinder
(
"su"
,
"id"
);
rtns
.
A
ctions
.
Add
(
action
);
action
.
Target
=
new
ElementFinder
(
"su"
,
"id"
);
rtns
.
A
ddAction
(
action
);
}
#
endregion
...
...
@@ -38,9 +38,9 @@ namespace Kivii.Test.WebDriver.Tests
var
action
=
new
OutputAction
();
action
.
Name
=
"取当前城市"
;
//使用XPath
action
.
ElementFinder
=
new
ElementFinder
(
"/html/body/div[3]/div[3]/div[1]/div[3]/div[1]/div/div/div[1]/div/div[1]/div[2]/div[1]/div[1]/div/div[1]"
);
action
.
Target
=
new
ElementFinder
(
"/html/body/div[3]/div[3]/div[1]/div[3]/div[1]/div/div/div[1]/div/div[1]/div[2]/div[1]/div[1]/div/div[1]"
);
action
.
Attributes
.
Add
(
"innerText"
,
"所在城市"
);
rtns
.
A
ctions
.
Add
(
action
);
rtns
.
A
ddAction
(
action
);
}
#
endregion
...
...
@@ -49,9 +49,9 @@ namespace Kivii.Test.WebDriver.Tests
var
action
=
new
OutputAction
();
action
.
Name
=
"取天气"
;
//使用XPath
action
.
ElementFinder
=
new
ElementFinder
(
".weather-main-temp_6CEpK > span:nth-child(1)"
,
"css"
);
action
.
Target
=
new
ElementFinder
(
".weather-main-temp_6CEpK > span:nth-child(1)"
,
"css"
);
action
.
Attributes
.
Add
(
"innerText"
,
"天气"
);
rtns
.
A
ctions
.
Add
(
action
);
rtns
.
A
ddAction
(
action
);
}
#
endregion
...
...
@@ -61,7 +61,7 @@ namespace Kivii.Test.WebDriver.Tests
action
.
Name
=
"测试JS返回"
;
//使用XPath
action
.
Js
=
"return '测试JS返回';"
;
rtns
.
A
ctions
.
Add
(
action
);
rtns
.
A
ddAction
(
action
);
}
#
endregion
return
rtns
;
...
...
packages.config
View file @
42609465
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"Kivii.WebDriver"
version
=
"4.15.2023.110
3
0"
targetFramework
=
"net472"
/>
<
package
id
=
"Kivii.WebDriver"
version
=
"4.15.2023.110
4
0"
targetFramework
=
"net472"
/>
<
package
id
=
"Newtonsoft.Json"
version
=
"13.0.1"
targetFramework
=
"net472"
/>
<
package
id
=
"Selenium.Support"
version
=
"4.15.0"
targetFramework
=
"net472"
/>
<
package
id
=
"Selenium.WebDriver"
version
=
"4.15.0"
targetFramework
=
"net472"
/>
...
...
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