Commit a4846853 by 施晓雨

更新示例

parent 42609465
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
this.label3 = new System.Windows.Forms.Label(); this.label3 = new System.Windows.Forms.Label();
this.cbxRemote = new System.Windows.Forms.CheckBox(); this.cbxRemote = new System.Windows.Forms.CheckBox();
this.groupBox1 = new System.Windows.Forms.GroupBox(); this.groupBox1 = new System.Windows.Forms.GroupBox();
this.cbxHidenLocalCommandWindow = new System.Windows.Forms.CheckBox();
this.btnSwitchWindow = new System.Windows.Forms.Button(); this.btnSwitchWindow = new System.Windows.Forms.Button();
this.panel5 = new System.Windows.Forms.Panel(); this.panel5 = new System.Windows.Forms.Panel();
this.lblCurrenWindow = new System.Windows.Forms.Label(); this.lblCurrenWindow = new System.Windows.Forms.Label();
...@@ -79,7 +80,7 @@ ...@@ -79,7 +80,7 @@
this.btnMouseDemo = new System.Windows.Forms.Button(); this.btnMouseDemo = new System.Windows.Forms.Button();
this.btnActionsDemo = new System.Windows.Forms.Button(); this.btnActionsDemo = new System.Windows.Forms.Button();
this.btnActionsJson = new System.Windows.Forms.Button(); this.btnActionsJson = new System.Windows.Forms.Button();
this.cbxHidenLocalCommandWindow = new System.Windows.Forms.CheckBox(); this.btnMofcomTest = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout(); this.groupBox1.SuspendLayout();
this.panel5.SuspendLayout(); this.panel5.SuspendLayout();
this.panel2.SuspendLayout(); this.panel2.SuspendLayout();
...@@ -193,6 +194,16 @@ ...@@ -193,6 +194,16 @@
this.groupBox1.TabStop = false; this.groupBox1.TabStop = false;
this.groupBox1.Text = "基础操作"; this.groupBox1.Text = "基础操作";
// //
// cbxHidenLocalCommandWindow
//
this.cbxHidenLocalCommandWindow.AutoSize = true;
this.cbxHidenLocalCommandWindow.Location = new System.Drawing.Point(163, 53);
this.cbxHidenLocalCommandWindow.Name = "cbxHidenLocalCommandWindow";
this.cbxHidenLocalCommandWindow.Size = new System.Drawing.Size(84, 16);
this.cbxHidenLocalCommandWindow.TabIndex = 15;
this.cbxHidenLocalCommandWindow.Text = "隐藏命令行";
this.cbxHidenLocalCommandWindow.UseVisualStyleBackColor = true;
//
// btnSwitchWindow // btnSwitchWindow
// //
this.btnSwitchWindow.Location = new System.Drawing.Point(238, 105); this.btnSwitchWindow.Location = new System.Drawing.Point(238, 105);
...@@ -561,7 +572,7 @@ ...@@ -561,7 +572,7 @@
this.tpWebScript.Location = new System.Drawing.Point(4, 22); this.tpWebScript.Location = new System.Drawing.Point(4, 22);
this.tpWebScript.Name = "tpWebScript"; this.tpWebScript.Name = "tpWebScript";
this.tpWebScript.Padding = new System.Windows.Forms.Padding(3); this.tpWebScript.Padding = new System.Windows.Forms.Padding(3);
this.tpWebScript.Size = new System.Drawing.Size(826, 237); this.tpWebScript.Size = new System.Drawing.Size(820, 237);
this.tpWebScript.TabIndex = 1; this.tpWebScript.TabIndex = 1;
this.tpWebScript.Tag = "web"; this.tpWebScript.Tag = "web";
this.tpWebScript.Text = "网页内执行"; this.tpWebScript.Text = "网页内执行";
...@@ -573,7 +584,7 @@ ...@@ -573,7 +584,7 @@
this.rtbWebScript.Dock = System.Windows.Forms.DockStyle.Fill; this.rtbWebScript.Dock = System.Windows.Forms.DockStyle.Fill;
this.rtbWebScript.Location = new System.Drawing.Point(3, 3); this.rtbWebScript.Location = new System.Drawing.Point(3, 3);
this.rtbWebScript.Name = "rtbWebScript"; this.rtbWebScript.Name = "rtbWebScript";
this.rtbWebScript.Size = new System.Drawing.Size(820, 211); this.rtbWebScript.Size = new System.Drawing.Size(814, 211);
this.rtbWebScript.TabIndex = 11; this.rtbWebScript.TabIndex = 11;
this.rtbWebScript.Text = ""; this.rtbWebScript.Text = "";
// //
...@@ -583,13 +594,13 @@ ...@@ -583,13 +594,13 @@
this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom; this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel1.Location = new System.Drawing.Point(3, 214); this.panel1.Location = new System.Drawing.Point(3, 214);
this.panel1.Name = "panel1"; this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(820, 20); this.panel1.Size = new System.Drawing.Size(814, 20);
this.panel1.TabIndex = 10; this.panel1.TabIndex = 10;
// //
// btnWindowExecuteScript // btnWindowExecuteScript
// //
this.btnWindowExecuteScript.Dock = System.Windows.Forms.DockStyle.Right; this.btnWindowExecuteScript.Dock = System.Windows.Forms.DockStyle.Right;
this.btnWindowExecuteScript.Location = new System.Drawing.Point(745, 0); this.btnWindowExecuteScript.Location = new System.Drawing.Point(739, 0);
this.btnWindowExecuteScript.Name = "btnWindowExecuteScript"; this.btnWindowExecuteScript.Name = "btnWindowExecuteScript";
this.btnWindowExecuteScript.Size = new System.Drawing.Size(75, 20); this.btnWindowExecuteScript.Size = new System.Drawing.Size(75, 20);
this.btnWindowExecuteScript.TabIndex = 5; this.btnWindowExecuteScript.TabIndex = 5;
...@@ -603,7 +614,7 @@ ...@@ -603,7 +614,7 @@
this.tpActionJson.Controls.Add(this.panel4); this.tpActionJson.Controls.Add(this.panel4);
this.tpActionJson.Location = new System.Drawing.Point(4, 22); this.tpActionJson.Location = new System.Drawing.Point(4, 22);
this.tpActionJson.Name = "tpActionJson"; this.tpActionJson.Name = "tpActionJson";
this.tpActionJson.Size = new System.Drawing.Size(826, 237); this.tpActionJson.Size = new System.Drawing.Size(820, 237);
this.tpActionJson.TabIndex = 2; this.tpActionJson.TabIndex = 2;
this.tpActionJson.Text = "Action自动化测试"; this.tpActionJson.Text = "Action自动化测试";
this.tpActionJson.UseVisualStyleBackColor = true; this.tpActionJson.UseVisualStyleBackColor = true;
...@@ -614,12 +625,13 @@ ...@@ -614,12 +625,13 @@
this.rtbActionsJson.Dock = System.Windows.Forms.DockStyle.Fill; this.rtbActionsJson.Dock = System.Windows.Forms.DockStyle.Fill;
this.rtbActionsJson.Location = new System.Drawing.Point(0, 0); this.rtbActionsJson.Location = new System.Drawing.Point(0, 0);
this.rtbActionsJson.Name = "rtbActionsJson"; this.rtbActionsJson.Name = "rtbActionsJson";
this.rtbActionsJson.Size = new System.Drawing.Size(826, 217); this.rtbActionsJson.Size = new System.Drawing.Size(820, 217);
this.rtbActionsJson.TabIndex = 13; this.rtbActionsJson.TabIndex = 13;
this.rtbActionsJson.Text = ""; this.rtbActionsJson.Text = "";
// //
// panel4 // panel4
// //
this.panel4.Controls.Add(this.btnMofcomTest);
this.panel4.Controls.Add(this.btnShowActionsTip); this.panel4.Controls.Add(this.btnShowActionsTip);
this.panel4.Controls.Add(this.btnMouseDemo); this.panel4.Controls.Add(this.btnMouseDemo);
this.panel4.Controls.Add(this.btnActionsDemo); this.panel4.Controls.Add(this.btnActionsDemo);
...@@ -627,7 +639,7 @@ ...@@ -627,7 +639,7 @@
this.panel4.Dock = System.Windows.Forms.DockStyle.Bottom; this.panel4.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel4.Location = new System.Drawing.Point(0, 217); this.panel4.Location = new System.Drawing.Point(0, 217);
this.panel4.Name = "panel4"; this.panel4.Name = "panel4";
this.panel4.Size = new System.Drawing.Size(826, 20); this.panel4.Size = new System.Drawing.Size(820, 20);
this.panel4.TabIndex = 12; this.panel4.TabIndex = 12;
// //
// btnShowActionsTip // btnShowActionsTip
...@@ -666,7 +678,7 @@ ...@@ -666,7 +678,7 @@
// btnActionsJson // btnActionsJson
// //
this.btnActionsJson.Dock = System.Windows.Forms.DockStyle.Right; this.btnActionsJson.Dock = System.Windows.Forms.DockStyle.Right;
this.btnActionsJson.Location = new System.Drawing.Point(751, 0); this.btnActionsJson.Location = new System.Drawing.Point(745, 0);
this.btnActionsJson.Name = "btnActionsJson"; this.btnActionsJson.Name = "btnActionsJson";
this.btnActionsJson.Size = new System.Drawing.Size(75, 20); this.btnActionsJson.Size = new System.Drawing.Size(75, 20);
this.btnActionsJson.TabIndex = 5; this.btnActionsJson.TabIndex = 5;
...@@ -674,17 +686,16 @@ ...@@ -674,17 +686,16 @@
this.btnActionsJson.UseVisualStyleBackColor = true; this.btnActionsJson.UseVisualStyleBackColor = true;
this.btnActionsJson.Click += new System.EventHandler(this.btnActionsJson_Click); this.btnActionsJson.Click += new System.EventHandler(this.btnActionsJson_Click);
// //
// cbxHidenLocalCommandWindow // btnMofcomTest
// //
this.cbxHidenLocalCommandWindow.AutoSize = true; this.btnMofcomTest.Dock = System.Windows.Forms.DockStyle.Left;
this.cbxHidenLocalCommandWindow.Checked = true; this.btnMofcomTest.Location = new System.Drawing.Point(216, 0);
this.cbxHidenLocalCommandWindow.CheckState = System.Windows.Forms.CheckState.Checked; this.btnMofcomTest.Name = "btnMofcomTest";
this.cbxHidenLocalCommandWindow.Location = new System.Drawing.Point(163, 53); this.btnMofcomTest.Size = new System.Drawing.Size(72, 20);
this.cbxHidenLocalCommandWindow.Name = "cbxHidenLocalCommandWindow"; this.btnMofcomTest.TabIndex = 17;
this.cbxHidenLocalCommandWindow.Size = new System.Drawing.Size(84, 16); this.btnMofcomTest.Text = "Mofcom";
this.cbxHidenLocalCommandWindow.TabIndex = 15; this.btnMofcomTest.UseVisualStyleBackColor = true;
this.cbxHidenLocalCommandWindow.Text = "隐藏命令行"; this.btnMofcomTest.Click += new System.EventHandler(this.btnMofcomTest_Click);
this.cbxHidenLocalCommandWindow.UseVisualStyleBackColor = true;
// //
// FrmMain // FrmMain
// //
...@@ -769,6 +780,7 @@ ...@@ -769,6 +780,7 @@
private System.Windows.Forms.ComboBox cbWindows; private System.Windows.Forms.ComboBox cbWindows;
private System.Windows.Forms.Button btnSwitchWindow; private System.Windows.Forms.Button btnSwitchWindow;
private System.Windows.Forms.CheckBox cbxHidenLocalCommandWindow; private System.Windows.Forms.CheckBox cbxHidenLocalCommandWindow;
private System.Windows.Forms.Button btnMofcomTest;
} }
} }
...@@ -295,7 +295,7 @@ namespace Kivii.Test.WebDriver ...@@ -295,7 +295,7 @@ namespace Kivii.Test.WebDriver
/// <param name="e"></param> /// <param name="e"></param>
private void btnNavigate_Click(object sender, EventArgs e) private void btnNavigate_Click(object sender, EventArgs e)
{ {
_manager?.CurrentWindow.NavigateTo(tbxUrl.Text); _manager?.CurrentWindow.GoTo(tbxUrl.Text);
} }
/// <summary> /// <summary>
...@@ -341,9 +341,9 @@ namespace Kivii.Test.WebDriver ...@@ -341,9 +341,9 @@ namespace Kivii.Test.WebDriver
/// <param name="e"></param> /// <param name="e"></param>
private void btnShowActionsTip_Click(object sender, EventArgs e) private void btnShowActionsTip_Click(object sender, EventArgs e)
{ {
foreach (var actionAttribute in ActionBase.GetActionAttributes()) foreach (var actionAttribute in ActionBase.AllActions())
{ {
appendMsg($"{actionAttribute.Type.FullName}{Environment.NewLine}别名:\"{actionAttribute.Alias}\" 描述:{actionAttribute.Description}"); appendMsg($"{actionAttribute.Type.FullName}{Environment.NewLine}别名:\"{actionAttribute.Alias}\" 名称:{actionAttribute.Name}{Environment.NewLine}描述:{actionAttribute.Description}");
} }
} }
private void cbWindows_Enter(object sender, EventArgs e) private void cbWindows_Enter(object sender, EventArgs e)
...@@ -408,11 +408,9 @@ namespace Kivii.Test.WebDriver ...@@ -408,11 +408,9 @@ namespace Kivii.Test.WebDriver
private void btnActionsJson_Click(object sender, EventArgs e) private void btnActionsJson_Click(object sender, EventArgs e)
{ {
if (_manager == null) return; if (_manager == null) return;
_manager.Maximize();//最大化网页
var window = new Window(_manager); _manager.CurrentWindow.ImportActions(rtbActionsJson.Text);
window.ImportActions(rtbActionsJson.Text); var rtns = _manager.CurrentWindow.ExecuteActions();
var rtns=window.ExecuteActions();
appendMsg($"执行结果:{Environment.NewLine}{rtns}"); appendMsg($"执行结果:{Environment.NewLine}{rtns}");
} }
...@@ -427,8 +425,8 @@ namespace Kivii.Test.WebDriver ...@@ -427,8 +425,8 @@ namespace Kivii.Test.WebDriver
/// <param name="e"></param> /// <param name="e"></param>
private void btnActionsDemo_Click(object sender, EventArgs e) private void btnActionsDemo_Click(object sender, EventArgs e)
{ {
var autoPage = WeatherTest.Get(); var actions = WeatherTest.GetActions();
var json = autoPage.ExportActions(true); var json = actions.ExportActions(true);
rtbActionsJson.Text = json; rtbActionsJson.Text = json;
} }
/// <summary> /// <summary>
...@@ -442,6 +440,12 @@ namespace Kivii.Test.WebDriver ...@@ -442,6 +440,12 @@ namespace Kivii.Test.WebDriver
var json = autoPage.ExportActions(true); var json = autoPage.ExportActions(true);
rtbActionsJson.Text = json; rtbActionsJson.Text = json;
} }
private void btnMofcomTest_Click(object sender, EventArgs e)
{
var autoPage = MofcomTest.Get();
var json = autoPage.ExportActions(true);
rtbActionsJson.Text = json;
}
......
...@@ -35,8 +35,8 @@ ...@@ -35,8 +35,8 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Kivii.WebDriver.V4.7, Version=4.15.2023.11040, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="Kivii.WebDriver.V4.7, Version=4.15.2023.11050, Culture=neutral, processorArchitecture=MSIL">
<HintPath>packages\Kivii.WebDriver.4.15.2023.11040\lib\net47\Kivii.WebDriver.V4.7.dll</HintPath> <HintPath>packages\Kivii.WebDriver.4.15.2023.11050\lib\net47\Kivii.WebDriver.V4.7.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <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> <HintPath>packages\Newtonsoft.Json.13.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
...@@ -68,6 +68,7 @@ ...@@ -68,6 +68,7 @@
</Compile> </Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Tests\MofcomTest.cs" />
<Compile Include="Tests\MouseTest.cs" /> <Compile Include="Tests\MouseTest.cs" />
<Compile Include="Tests\ReferenceTest.cs" /> <Compile Include="Tests\ReferenceTest.cs" />
<Compile Include="Tests\WeatherTest.cs" /> <Compile Include="Tests\WeatherTest.cs" />
......
using Kivii.WebDriver;
using Kivii.WebDriver.Actions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Kivii.Test.WebDriver.Tests
{
internal class MofcomTest
{
public static Window Get()
{
var rtns = new Window(null);
#region 打开网站,放在Action中执行了,不需要设autoPage.Url
{
var action = new NavigateAction();
action.Name = "跳转网站";
action.Url = "http://www.cacs.mofcom.gov.cn/cacscms/view/notice/zhtbomrasff#";
rtns.Actions.Add(action);
}
#endregion
#region 暂停2
{
var action = new SleepAction();
action.PauseMilliseconds = 2000;
rtns.Actions.Add(action);
}
#endregion
#region 移动鼠标至第1个元素上点击
{
var action = new ClickAction();
action.Target = new ElementFinder("//*[@id=\"zhtbomrasff\"]");
rtns.Actions.Add(action);
}
#endregion
#region 暂停2
{
var action = new SleepAction();
action.Name = "准备抓取网页";
action.PauseMilliseconds = 2000;
rtns.Actions.Add(action);
}
#endregion
#region 抓取内容
{
var action = new JavascriptAction();
action.Script="return '抓取当前页内容'";
rtns.Actions.Add(action);
}
#endregion
#region 点击下一页
{
var action = new ClickAction();
action.Target = new ElementFinder()
{
Type = ElementFindType.LinkText,
Selector = "下一页"
};
rtns.Actions.Add(action);
}
#endregion
#region 循环10
{
var action = new LoopAction();
action.LoopTimes =10;
action.FromName = "准备抓取网页";
rtns.Actions.Add(action);
}
#endregion
return rtns;
}
}
}
...@@ -21,7 +21,7 @@ namespace Kivii.Test.WebDriver.Tests ...@@ -21,7 +21,7 @@ namespace Kivii.Test.WebDriver.Tests
var action = new NavigateAction(); var action = new NavigateAction();
action.Name = "跳转网站"; action.Name = "跳转网站";
action.Url = "http://www.cacs.mofcom.gov.cn/cacscms/view/notice/zhtbomrasff#"; action.Url = "http://www.cacs.mofcom.gov.cn/cacscms/view/notice/zhtbomrasff#";
rtns.AddAction(action); rtns.Actions.Add(action);
} }
#endregion #endregion
...@@ -29,8 +29,8 @@ namespace Kivii.Test.WebDriver.Tests ...@@ -29,8 +29,8 @@ namespace Kivii.Test.WebDriver.Tests
{ {
var action = new MouseAction(); var action = new MouseAction();
action.Type = MouseActionType.Pause; action.Type = MouseActionType.Pause;
action.DurationMilliseconds = 2000; action.PauseMilliseconds = 2000;
rtns.AddAction(action); rtns.Actions.Add(action);
} }
#endregion #endregion
...@@ -39,7 +39,7 @@ namespace Kivii.Test.WebDriver.Tests ...@@ -39,7 +39,7 @@ namespace Kivii.Test.WebDriver.Tests
var action = new MouseAction(); var action = new MouseAction();
action.Type = MouseActionType.Click; action.Type = MouseActionType.Click;
action.Target = new ElementFinder("//*[@id=\"zhtbomrasff\"]"); action.Target = new ElementFinder("//*[@id=\"zhtbomrasff\"]");
rtns.AddAction(action); rtns.Actions.Add(action);
} }
#endregion #endregion
...@@ -47,8 +47,8 @@ namespace Kivii.Test.WebDriver.Tests ...@@ -47,8 +47,8 @@ namespace Kivii.Test.WebDriver.Tests
{ {
var action = new MouseAction(); var action = new MouseAction();
action.Type = MouseActionType.Pause; action.Type = MouseActionType.Pause;
action.DurationMilliseconds = 2000; action.PauseMilliseconds = 2000;
rtns.AddAction(action); rtns.Actions.Add(action);
} }
#endregion #endregion
...@@ -57,7 +57,7 @@ namespace Kivii.Test.WebDriver.Tests ...@@ -57,7 +57,7 @@ namespace Kivii.Test.WebDriver.Tests
var action = new MouseAction(); var action = new MouseAction();
action.Type = MouseActionType.Click; action.Type = MouseActionType.Click;
action.Target = new ElementFinder("//*[@id=\"zhtbomrapex\"]"); action.Target = new ElementFinder("//*[@id=\"zhtbomrapex\"]");
rtns.AddAction(action); rtns.Actions.Add(action);
} }
#endregion #endregion
...@@ -65,8 +65,8 @@ namespace Kivii.Test.WebDriver.Tests ...@@ -65,8 +65,8 @@ namespace Kivii.Test.WebDriver.Tests
{ {
var action = new MouseAction(); var action = new MouseAction();
action.Type = MouseActionType.Pause; action.Type = MouseActionType.Pause;
action.DurationMilliseconds = 2000; action.PauseMilliseconds = 2000;
rtns.AddAction(action); rtns.Actions.Add(action);
} }
#endregion #endregion
...@@ -75,7 +75,7 @@ namespace Kivii.Test.WebDriver.Tests ...@@ -75,7 +75,7 @@ namespace Kivii.Test.WebDriver.Tests
var action = new MouseAction(); var action = new MouseAction();
action.Type = MouseActionType.Click; action.Type = MouseActionType.Click;
action.Target = new ElementFinder("//*[@id=\"zhtbmg\"]"); action.Target = new ElementFinder("//*[@id=\"zhtbmg\"]");
rtns.AddAction(action); rtns.Actions.Add(action);
} }
#endregion #endregion
...@@ -83,8 +83,8 @@ namespace Kivii.Test.WebDriver.Tests ...@@ -83,8 +83,8 @@ namespace Kivii.Test.WebDriver.Tests
{ {
var action = new MouseAction(); var action = new MouseAction();
action.Type = MouseActionType.Pause; action.Type = MouseActionType.Pause;
action.DurationMilliseconds = 2000; action.PauseMilliseconds = 2000;
rtns.AddAction(action); rtns.Actions.Add(action);
} }
#endregion #endregion
...@@ -93,7 +93,7 @@ namespace Kivii.Test.WebDriver.Tests ...@@ -93,7 +93,7 @@ namespace Kivii.Test.WebDriver.Tests
var action = new MouseAction(); var action = new MouseAction();
action.Type = MouseActionType.Click; action.Type = MouseActionType.Click;
action.Target = new ElementFinder("//*[@id=\"zhtbomrasff\"]"); action.Target = new ElementFinder("//*[@id=\"zhtbomrasff\"]");
rtns.AddAction(action); rtns.Actions.Add(action);
} }
#endregion #endregion
...@@ -101,7 +101,7 @@ namespace Kivii.Test.WebDriver.Tests ...@@ -101,7 +101,7 @@ namespace Kivii.Test.WebDriver.Tests
{ {
var action = new MouseAction(); var action = new MouseAction();
action.Type = MouseActionType.Perform; action.Type = MouseActionType.Perform;
rtns.AddAction(action); rtns.Actions.Add(action);
} }
#endregion #endregion
return rtns; return rtns;
......
...@@ -10,17 +10,25 @@ namespace Kivii.Test.WebDriver.Tests ...@@ -10,17 +10,25 @@ namespace Kivii.Test.WebDriver.Tests
{ {
internal class WeatherTest internal class WeatherTest
{ {
public static Window Get() public static Window GetActions()
{ {
var rtns = new Window(null); var rtns = new Window(null);
//autoPage.Url = "https://www.baidu.com";//生成DEMO时不需要 //autoPage.Url = "https://www.baidu.com";//生成DEMO时不需要
#region 导航到Baidu
{
var action = new NavigateAction();
action.Url = "https://www.baidu.com";
rtns.Actions.Add(action);
}
#endregion
#region 第一步,在输入框内输入内容 #region 第一步,在输入框内输入内容
{ {
var action = new InputAction(); var action = new InputAction();
action.Name = "输入查询内容"; action.Name = "输入查询内容";
action.InputValue = "最近天气"; action.InputValue = "最近天气";
action.Target = new ElementFinder("kw", "id"); action.Target = new ElementFinder("kw", "id");
rtns.AddAction(action); rtns.Actions.Add(action);
} }
#endregion #endregion
...@@ -29,7 +37,7 @@ namespace Kivii.Test.WebDriver.Tests ...@@ -29,7 +37,7 @@ namespace Kivii.Test.WebDriver.Tests
var action = new ClickAction(); var action = new ClickAction();
action.Name = "百度一下"; action.Name = "百度一下";
action.Target = new ElementFinder("su", "id"); action.Target = new ElementFinder("su", "id");
rtns.AddAction(action); rtns.Actions.Add(action);
} }
#endregion #endregion
...@@ -40,7 +48,7 @@ namespace Kivii.Test.WebDriver.Tests ...@@ -40,7 +48,7 @@ namespace Kivii.Test.WebDriver.Tests
//使用XPath //使用XPath
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.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", "所在城市"); action.Attributes.Add("innerText", "所在城市");
rtns.AddAction(action); rtns.Actions.Add(action);
} }
#endregion #endregion
...@@ -51,7 +59,7 @@ namespace Kivii.Test.WebDriver.Tests ...@@ -51,7 +59,7 @@ namespace Kivii.Test.WebDriver.Tests
//使用XPath //使用XPath
action.Target = 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", "天气"); action.Attributes.Add("innerText", "天气");
rtns.AddAction(action); rtns.Actions.Add(action);
} }
#endregion #endregion
...@@ -61,7 +69,7 @@ namespace Kivii.Test.WebDriver.Tests ...@@ -61,7 +69,7 @@ namespace Kivii.Test.WebDriver.Tests
action.Name = "测试JS返回"; action.Name = "测试JS返回";
//使用XPath //使用XPath
action.Js = "return '测试JS返回';"; action.Js = "return '测试JS返回';";
rtns.AddAction(action); rtns.Actions.Add(action);
} }
#endregion #endregion
return rtns; return rtns;
......
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="Kivii.WebDriver" version="4.15.2023.11040" targetFramework="net472" /> <package id="Kivii.WebDriver" version="4.15.2023.11050" targetFramework="net472" />
<package id="Newtonsoft.Json" version="13.0.1" 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.Support" version="4.15.0" targetFramework="net472" />
<package id="Selenium.WebDriver" version="4.15.0" targetFramework="net472" /> <package id="Selenium.WebDriver" version="4.15.0" targetFramework="net472" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment