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
367e3f11
Commit
367e3f11
authored
Nov 15, 2023
by
施晓雨
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新示例代码
parent
a4846853
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
130 additions
and
35 deletions
+130
-35
FrmMain.Designer.cs
FrmMain.Designer.cs
+90
-24
FrmMain.cs
FrmMain.cs
+31
-6
Kivii.Test.WebDriver.csproj
Kivii.Test.WebDriver.csproj
+2
-2
MofcomTest.cs
Tests/MofcomTest.cs
+6
-2
packages.config
packages.config
+1
-1
No files found.
FrmMain.Designer.cs
View file @
367e3f11
...
...
@@ -36,6 +36,10 @@
this
.
label3
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
cbxRemote
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
groupBox1
=
new
System
.
Windows
.
Forms
.
GroupBox
();
this
.
cbBrowserCssless
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
cbBrowserImageless
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
cbBrowserUndetected
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
cbBrowserHeadless
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
cbxHidenLocalCommandWindow
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
btnSwitchWindow
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
panel5
=
new
System
.
Windows
.
Forms
.
Panel
();
...
...
@@ -76,11 +80,12 @@
this
.
tpActionJson
=
new
System
.
Windows
.
Forms
.
TabPage
();
this
.
rtbActionsJson
=
new
System
.
Windows
.
Forms
.
RichTextBox
();
this
.
panel4
=
new
System
.
Windows
.
Forms
.
Panel
();
this
.
btnMofcomTest
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnShowActionsTip
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnMouseDemo
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnActionsDemo
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnActionsJson
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btn
MofcomTest
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btn
ImportActions
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
groupBox1
.
SuspendLayout
();
this
.
panel5
.
SuspendLayout
();
this
.
panel2
.
SuspendLayout
();
...
...
@@ -99,7 +104,7 @@
//
// btnInitialize
//
this
.
btnInitialize
.
Location
=
new
System
.
Drawing
.
Point
(
6
,
79
);
this
.
btnInitialize
.
Location
=
new
System
.
Drawing
.
Point
(
6
,
133
);
this
.
btnInitialize
.
Name
=
"btnInitialize"
;
this
.
btnInitialize
.
Size
=
new
System
.
Drawing
.
Size
(
53
,
23
);
this
.
btnInitialize
.
TabIndex
=
0
;
...
...
@@ -109,7 +114,7 @@
//
// btnDispose
//
this
.
btnDispose
.
Location
=
new
System
.
Drawing
.
Point
(
73
,
79
);
this
.
btnDispose
.
Location
=
new
System
.
Drawing
.
Point
(
73
,
133
);
this
.
btnDispose
.
Name
=
"btnDispose"
;
this
.
btnDispose
.
Size
=
new
System
.
Drawing
.
Size
(
54
,
23
);
this
.
btnDispose
.
TabIndex
=
0
;
...
...
@@ -142,7 +147,7 @@
//
// btnScreenshot
//
this
.
btnScreenshot
.
Location
=
new
System
.
Drawing
.
Point
(
133
,
79
);
this
.
btnScreenshot
.
Location
=
new
System
.
Drawing
.
Point
(
133
,
133
);
this
.
btnScreenshot
.
Name
=
"btnScreenshot"
;
this
.
btnScreenshot
.
Size
=
new
System
.
Drawing
.
Size
(
55
,
23
);
this
.
btnScreenshot
.
TabIndex
=
0
;
...
...
@@ -172,6 +177,10 @@
//
// groupBox1
//
this
.
groupBox1
.
Controls
.
Add
(
this
.
cbBrowserCssless
);
this
.
groupBox1
.
Controls
.
Add
(
this
.
cbBrowserImageless
);
this
.
groupBox1
.
Controls
.
Add
(
this
.
cbBrowserUndetected
);
this
.
groupBox1
.
Controls
.
Add
(
this
.
cbBrowserHeadless
);
this
.
groupBox1
.
Controls
.
Add
(
this
.
cbxHidenLocalCommandWindow
);
this
.
groupBox1
.
Controls
.
Add
(
this
.
btnSwitchWindow
);
this
.
groupBox1
.
Controls
.
Add
(
this
.
panel5
);
...
...
@@ -189,24 +198,64 @@
this
.
groupBox1
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Top
;
this
.
groupBox1
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
0
);
this
.
groupBox1
.
Name
=
"groupBox1"
;
this
.
groupBox1
.
Size
=
new
System
.
Drawing
.
Size
(
293
,
18
4
);
this
.
groupBox1
.
Size
=
new
System
.
Drawing
.
Size
(
293
,
22
4
);
this
.
groupBox1
.
TabIndex
=
8
;
this
.
groupBox1
.
TabStop
=
false
;
this
.
groupBox1
.
Text
=
"基础操作"
;
//
// cbBrowserCssless
//
this
.
cbBrowserCssless
.
AutoSize
=
true
;
this
.
cbBrowserCssless
.
Location
=
new
System
.
Drawing
.
Point
(
95
,
103
);
this
.
cbBrowserCssless
.
Name
=
"cbBrowserCssless"
;
this
.
cbBrowserCssless
.
Size
=
new
System
.
Drawing
.
Size
(
72
,
16
);
this
.
cbBrowserCssless
.
TabIndex
=
19
;
this
.
cbBrowserCssless
.
Text
=
"禁用样式"
;
this
.
cbBrowserCssless
.
UseVisualStyleBackColor
=
true
;
//
// cbBrowserImageless
//
this
.
cbBrowserImageless
.
AutoSize
=
true
;
this
.
cbBrowserImageless
.
Location
=
new
System
.
Drawing
.
Point
(
6
,
103
);
this
.
cbBrowserImageless
.
Name
=
"cbBrowserImageless"
;
this
.
cbBrowserImageless
.
Size
=
new
System
.
Drawing
.
Size
(
72
,
16
);
this
.
cbBrowserImageless
.
TabIndex
=
18
;
this
.
cbBrowserImageless
.
Text
=
"禁用图片"
;
this
.
cbBrowserImageless
.
UseVisualStyleBackColor
=
true
;
//
// cbBrowserUndetected
//
this
.
cbBrowserUndetected
.
AutoSize
=
true
;
this
.
cbBrowserUndetected
.
Location
=
new
System
.
Drawing
.
Point
(
178
,
78
);
this
.
cbBrowserUndetected
.
Name
=
"cbBrowserUndetected"
;
this
.
cbBrowserUndetected
.
Size
=
new
System
.
Drawing
.
Size
(
72
,
16
);
this
.
cbBrowserUndetected
.
TabIndex
=
17
;
this
.
cbBrowserUndetected
.
Text
=
"隐藏特征"
;
this
.
cbBrowserUndetected
.
UseVisualStyleBackColor
=
true
;
//
// cbBrowserHeadless
//
this
.
cbBrowserHeadless
.
AutoSize
=
true
;
this
.
cbBrowserHeadless
.
Location
=
new
System
.
Drawing
.
Point
(
95
,
78
);
this
.
cbBrowserHeadless
.
Name
=
"cbBrowserHeadless"
;
this
.
cbBrowserHeadless
.
Size
=
new
System
.
Drawing
.
Size
(
72
,
16
);
this
.
cbBrowserHeadless
.
TabIndex
=
16
;
this
.
cbBrowserHeadless
.
Text
=
"无头模式"
;
this
.
cbBrowserHeadless
.
UseVisualStyleBackColor
=
true
;
//
// cbxHidenLocalCommandWindow
//
this
.
cbxHidenLocalCommandWindow
.
AutoSize
=
true
;
this
.
cbxHidenLocalCommandWindow
.
Location
=
new
System
.
Drawing
.
Point
(
163
,
53
);
this
.
cbxHidenLocalCommandWindow
.
Location
=
new
System
.
Drawing
.
Point
(
5
,
81
);
this
.
cbxHidenLocalCommandWindow
.
Name
=
"cbxHidenLocalCommandWindow"
;
this
.
cbxHidenLocalCommandWindow
.
Size
=
new
System
.
Drawing
.
Size
(
84
,
16
);
this
.
cbxHidenLocalCommandWindow
.
Size
=
new
System
.
Drawing
.
Size
(
72
,
16
);
this
.
cbxHidenLocalCommandWindow
.
TabIndex
=
15
;
this
.
cbxHidenLocalCommandWindow
.
Text
=
"隐藏
命令行
"
;
this
.
cbxHidenLocalCommandWindow
.
Text
=
"隐藏
服务
"
;
this
.
cbxHidenLocalCommandWindow
.
UseVisualStyleBackColor
=
true
;
//
// btnSwitchWindow
//
this
.
btnSwitchWindow
.
Location
=
new
System
.
Drawing
.
Point
(
238
,
1
05
);
this
.
btnSwitchWindow
.
Location
=
new
System
.
Drawing
.
Point
(
238
,
1
59
);
this
.
btnSwitchWindow
.
Name
=
"btnSwitchWindow"
;
this
.
btnSwitchWindow
.
Size
=
new
System
.
Drawing
.
Size
(
49
,
23
);
this
.
btnSwitchWindow
.
TabIndex
=
14
;
...
...
@@ -219,7 +268,7 @@
this
.
panel5
.
Controls
.
Add
(
this
.
lblCurrenWindow
);
this
.
panel5
.
Controls
.
Add
(
this
.
btnCloseCurrentWindow
);
this
.
panel5
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Bottom
;
this
.
panel5
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
1
4
3
);
this
.
panel5
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
1
8
3
);
this
.
panel5
.
Name
=
"panel5"
;
this
.
panel5
.
Size
=
new
System
.
Drawing
.
Size
(
287
,
38
);
this
.
panel5
.
TabIndex
=
13
;
...
...
@@ -247,7 +296,7 @@
// label7
//
this
.
label7
.
AutoSize
=
true
;
this
.
label7
.
Location
=
new
System
.
Drawing
.
Point
(
1
,
1
13
);
this
.
label7
.
Location
=
new
System
.
Drawing
.
Point
(
1
,
1
67
);
this
.
label7
.
Name
=
"label7"
;
this
.
label7
.
Size
=
new
System
.
Drawing
.
Size
(
59
,
12
);
this
.
label7
.
TabIndex
=
10
;
...
...
@@ -257,7 +306,7 @@
//
this
.
cbWindows
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
cbWindows
.
FormattingEnabled
=
true
;
this
.
cbWindows
.
Location
=
new
System
.
Drawing
.
Point
(
72
,
1
07
);
this
.
cbWindows
.
Location
=
new
System
.
Drawing
.
Point
(
72
,
1
61
);
this
.
cbWindows
.
Name
=
"cbWindows"
;
this
.
cbWindows
.
Size
=
new
System
.
Drawing
.
Size
(
163
,
20
);
this
.
cbWindows
.
TabIndex
=
11
;
...
...
@@ -299,7 +348,7 @@
// groupBox3
//
this
.
groupBox3
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Top
;
this
.
groupBox3
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
3
3
1
);
this
.
groupBox3
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
3
7
1
);
this
.
groupBox3
.
Name
=
"groupBox3"
;
this
.
groupBox3
.
Size
=
new
System
.
Drawing
.
Size
(
293
,
136
);
this
.
groupBox3
.
TabIndex
=
12
;
...
...
@@ -318,7 +367,7 @@
this
.
groupBox2
.
Controls
.
Add
(
this
.
tbxVarName
);
this
.
groupBox2
.
Controls
.
Add
(
this
.
tbxScriptPath
);
this
.
groupBox2
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Top
;
this
.
groupBox2
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
18
4
);
this
.
groupBox2
.
Location
=
new
System
.
Drawing
.
Point
(
0
,
22
4
);
this
.
groupBox2
.
Name
=
"groupBox2"
;
this
.
groupBox2
.
Size
=
new
System
.
Drawing
.
Size
(
293
,
147
);
this
.
groupBox2
.
TabIndex
=
10
;
...
...
@@ -631,6 +680,7 @@
//
// panel4
//
this
.
panel4
.
Controls
.
Add
(
this
.
btnImportActions
);
this
.
panel4
.
Controls
.
Add
(
this
.
btnMofcomTest
);
this
.
panel4
.
Controls
.
Add
(
this
.
btnShowActionsTip
);
this
.
panel4
.
Controls
.
Add
(
this
.
btnMouseDemo
);
...
...
@@ -642,6 +692,17 @@
this
.
panel4
.
Size
=
new
System
.
Drawing
.
Size
(
820
,
20
);
this
.
panel4
.
TabIndex
=
12
;
//
// btnMofcomTest
//
this
.
btnMofcomTest
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Left
;
this
.
btnMofcomTest
.
Location
=
new
System
.
Drawing
.
Point
(
216
,
0
);
this
.
btnMofcomTest
.
Name
=
"btnMofcomTest"
;
this
.
btnMofcomTest
.
Size
=
new
System
.
Drawing
.
Size
(
72
,
20
);
this
.
btnMofcomTest
.
TabIndex
=
17
;
this
.
btnMofcomTest
.
Text
=
"Mofcom"
;
this
.
btnMofcomTest
.
UseVisualStyleBackColor
=
true
;
this
.
btnMofcomTest
.
Click
+=
new
System
.
EventHandler
(
this
.
btnMofcomTest_Click
);
//
// btnShowActionsTip
//
this
.
btnShowActionsTip
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Left
;
...
...
@@ -686,16 +747,16 @@
this
.
btnActionsJson
.
UseVisualStyleBackColor
=
true
;
this
.
btnActionsJson
.
Click
+=
new
System
.
EventHandler
(
this
.
btnActionsJson_Click
);
//
// btn
MofcomTest
// btn
ImportActions
//
this
.
btn
MofcomTest
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Lef
t
;
this
.
btn
MofcomTest
.
Location
=
new
System
.
Drawing
.
Point
(
216
,
0
);
this
.
btn
MofcomTest
.
Name
=
"btnMofcomTest
"
;
this
.
btn
MofcomTest
.
Size
=
new
System
.
Drawing
.
Size
(
72
,
20
);
this
.
btn
MofcomTest
.
TabIndex
=
17
;
this
.
btn
MofcomTest
.
Text
=
"Mofcom
"
;
this
.
btn
MofcomTest
.
UseVisualStyleBackColor
=
true
;
this
.
btn
MofcomTest
.
Click
+=
new
System
.
EventHandler
(
this
.
btnMofcomTest
_Click
);
this
.
btn
ImportActions
.
Dock
=
System
.
Windows
.
Forms
.
DockStyle
.
Righ
t
;
this
.
btn
ImportActions
.
Location
=
new
System
.
Drawing
.
Point
(
670
,
0
);
this
.
btn
ImportActions
.
Name
=
"btnImportActions
"
;
this
.
btn
ImportActions
.
Size
=
new
System
.
Drawing
.
Size
(
75
,
20
);
this
.
btn
ImportActions
.
TabIndex
=
18
;
this
.
btn
ImportActions
.
Text
=
"导入脚本
"
;
this
.
btn
ImportActions
.
UseVisualStyleBackColor
=
true
;
this
.
btn
ImportActions
.
Click
+=
new
System
.
EventHandler
(
this
.
btnImportActions
_Click
);
//
// FrmMain
//
...
...
@@ -705,7 +766,7 @@
this
.
Controls
.
Add
(
this
.
panel3
);
this
.
Controls
.
Add
(
this
.
panel2
);
this
.
Name
=
"FrmMain"
;
this
.
Text
=
"
代码测试
"
;
this
.
Text
=
"
网页自动化工具-功能演示
"
;
this
.
groupBox1
.
ResumeLayout
(
false
);
this
.
groupBox1
.
PerformLayout
();
this
.
panel5
.
ResumeLayout
(
false
);
...
...
@@ -781,6 +842,11 @@
private
System
.
Windows
.
Forms
.
Button
btnSwitchWindow
;
private
System
.
Windows
.
Forms
.
CheckBox
cbxHidenLocalCommandWindow
;
private
System
.
Windows
.
Forms
.
Button
btnMofcomTest
;
private
System
.
Windows
.
Forms
.
CheckBox
cbBrowserHeadless
;
private
System
.
Windows
.
Forms
.
CheckBox
cbBrowserUndetected
;
private
System
.
Windows
.
Forms
.
CheckBox
cbBrowserImageless
;
private
System
.
Windows
.
Forms
.
CheckBox
cbBrowserCssless
;
private
System
.
Windows
.
Forms
.
Button
btnImportActions
;
}
}
FrmMain.cs
View file @
367e3f11
...
...
@@ -49,6 +49,8 @@ namespace Kivii.Test.WebDriver
_manager
.
OnException
+=
manager_OnException
;
_manager
.
OnCurrentWindowChanged
+=
manager_OnWindowChanged
;
_manager
.
OnActionExecuted
+=
manager_OnActionExecuted
;
_manager
.
OnActionException
+=
manager_OnActionException
;
//以下是WebDriver的事件
_manager
.
ElementClicked
+=
EventDriver_ElementClicked
;
_manager
.
ElementClicking
+=
EventDriver_ElementClicking
;
...
...
@@ -69,6 +71,16 @@ namespace Kivii.Test.WebDriver
_manager
.
ScriptExecuting
+=
EventDriver_ScriptExecuting
;
}
private
void
manager_OnActionException
(
Window
sender
,
Exception
e
)
{
appendMsg
(
$"动作执行异常:
{
DateTime
.
Now
}{
Environment
.
NewLine
}{
e
.
Message
}{
Environment
.
NewLine
}{
e
.
StackTrace
}
"
);
}
private
void
manager_OnActionExecuted
(
Window
sender
,
string
e
)
{
appendMsg
(
$"动作执行成功:
{
DateTime
.
Now
}{
Environment
.
NewLine
}{
e
}
"
);
}
private
void
manager_OnWindowChanged
(
object
sender
,
Window
e
)
{
lblCurrenWindow
.
Text
=
$"当前窗口:
{(
_manager
?.
StartWindow
==
_manager
.
CurrentWindow
?
"主窗口"
:
"子窗口"
)}{
Environment
.
NewLine
}{
e
.
Handle
}{
Environment
.
NewLine
}
标题:
{
e
.
Title
}
"
;
...
...
@@ -235,7 +247,12 @@ namespace Kivii.Test.WebDriver
if
(
_manager
!=
null
)
return
;
rtbMsg
.
Clear
();
_manager
=
new
Manager
();
_manager
.
HideCommandPromptWindow
=
cbxHidenLocalCommandWindow
.
Checked
;
//如果是本地运行,可选择隐藏本地服务的命令行
if
(
cbBrowserUndetected
.
Checked
)
_manager
.
Options
|=
BrowserOption
.
Undetected
;
//不显示浏览器
if
(
cbBrowserHeadless
.
Checked
)
_manager
.
Options
|=
BrowserOption
.
Headless
;
//不显示浏览器
if
(
cbBrowserImageless
.
Checked
)
_manager
.
Options
|=
BrowserOption
.
Imageless
;
//不显示浏览器
if
(
cbBrowserCssless
.
Checked
)
_manager
.
Options
|=
BrowserOption
.
Cssless
;
//不显示浏览器
_manager
.
HideLocalService
=
cbxHidenLocalCommandWindow
.
Checked
;
//如果是本地运行,可选择隐藏本地服务的命令行
addListener
();
//管理器的2个事件是直接可以监听的,WebDriver的事件是需要等初始化完才能监听的
var
serviceUrl
=
string
.
Empty
;
if
(
cbxRemote
.
Checked
)
...
...
@@ -446,11 +463,19 @@ namespace Kivii.Test.WebDriver
var
json
=
autoPage
.
ExportActions
(
true
);
rtbActionsJson
.
Text
=
json
;
}
/// <summary>
/// 导入JSON文件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private
void
btnImportActions_Click
(
object
sender
,
EventArgs
e
)
{
var
ofd
=
new
OpenFileDialog
();
ofd
.
Filter
=
"脚本文件|*.json"
;
if
(
ofd
.
ShowDialog
()
!=
DialogResult
.
OK
)
return
;
var
json
=
System
.
IO
.
File
.
ReadAllText
(
ofd
.
FileName
);
rtbActionsJson
.
Text
=
json
;
}
#
endregion
}
}
Kivii.Test.WebDriver.csproj
View file @
367e3f11
...
...
@@ -35,8 +35,8 @@
<WarningLevel>
4
</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference
Include=
"Kivii.WebDriver.V4.7, Version=4.15.2023.110
5
0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
packages\Kivii.WebDriver.4.15.2023.110
5
0\lib\net47\Kivii.WebDriver.V4.7.dll
</HintPath>
<Reference
Include=
"Kivii.WebDriver.V4.7, Version=4.15.2023.110
6
0, Culture=neutral, processorArchitecture=MSIL"
>
<HintPath>
packages\Kivii.WebDriver.4.15.2023.110
6
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>
...
...
Tests/MofcomTest.cs
View file @
367e3f11
...
...
@@ -26,6 +26,7 @@ namespace Kivii.Test.WebDriver.Tests
#
region
暂停
2
秒
{
var
action
=
new
SleepAction
();
action
.
Name
=
"暂停2秒"
;
action
.
PauseMilliseconds
=
2000
;
rtns
.
Actions
.
Add
(
action
);
}
...
...
@@ -34,6 +35,7 @@ namespace Kivii.Test.WebDriver.Tests
#
region
移动鼠标至第
1
个元素上点击
{
var
action
=
new
ClickAction
();
action
.
Name
=
"移至第一个标签"
;
action
.
Target
=
new
ElementFinder
(
"//*[@id=\"zhtbomrasff\"]"
);
rtns
.
Actions
.
Add
(
action
);
}
...
...
@@ -42,7 +44,7 @@ namespace Kivii.Test.WebDriver.Tests
#
region
暂停
2
秒
{
var
action
=
new
SleepAction
();
action
.
Name
=
"
准备
抓取网页"
;
action
.
Name
=
"
等待
抓取网页"
;
action
.
PauseMilliseconds
=
2000
;
rtns
.
Actions
.
Add
(
action
);
}
...
...
@@ -51,6 +53,7 @@ namespace Kivii.Test.WebDriver.Tests
#
region
抓取内容
{
var
action
=
new
JavascriptAction
();
action
.
Name
=
"执行脚本"
;
action
.
Script
=
"return '抓取当前页内容'"
;
rtns
.
Actions
.
Add
(
action
);
}
...
...
@@ -59,6 +62,7 @@ namespace Kivii.Test.WebDriver.Tests
#
region
点击下一页
{
var
action
=
new
ClickAction
();
action
.
Name
=
"点击下一页"
;
action
.
Target
=
new
ElementFinder
()
{
Type
=
ElementFindType
.
LinkText
,
...
...
@@ -72,7 +76,7 @@ namespace Kivii.Test.WebDriver.Tests
{
var
action
=
new
LoopAction
();
action
.
LoopTimes
=
10
;
action
.
FromName
=
"
准备
抓取网页"
;
action
.
FromName
=
"
等待
抓取网页"
;
rtns
.
Actions
.
Add
(
action
);
}
#
endregion
...
...
packages.config
View file @
367e3f11
<?
xml
version
=
"1.0"
encoding
=
"utf-8"
?>
<
packages
>
<
package
id
=
"Kivii.WebDriver"
version
=
"4.15.2023.110
5
0"
targetFramework
=
"net472"
/>
<
package
id
=
"Kivii.WebDriver"
version
=
"4.15.2023.110
6
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