C# 无法返回到我的另一个类文件 [英] C# Not able to return to my another class file

查看:53
本文介绍了C# 无法返回到我的另一个类文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个自动化系统,但我在这里遇到了一个问题.以下是简要说明

I am trying to create an automation system but I am facing a problem here. Below is the brief description

main.cs

[Test]
public void Test_MyPage()
{
    LoginPageObject objLogin = new LoginPageObject();
    FunctionTest cc = objLogin.FunctionAbcTest();
    FunctionTest objAbcTest = new FunctionTest();
}

LoginPageObject.cs

// Login Functionality
//public void Login (some args){...}
// And
public FunctionTest FunctionAbcTest()
{
    //some functions to be called   .....(1)
    return new FunctionTest();
}

FunctionTest.cs
//Test automation functions are called

预期结果:返回FunctionTest类继续进一步测试

Expected Result: To return to FunctionTest class to continue further test

实际结果:在(1)中调用的某个函数之后,它自动化完成但不返回到 FunctionTest.cs

Actual Result: After some function which is called in (1) it automation gets completed but does not return to FunctionTest.cs

我真的需要这方面的帮助.

I really need help with this.

非常感谢您的帮助.

请注意:

  1. 更多描述,你可以参考我的项目.点击此处.

请添加打开excel文件的完整路径

Please add full path to open excel file

安装 MS Access 数据库引擎 2010(32 位或 64 位,具体取决于您的机器).

Install MS Access Database engine 2010 (either 32bit or 64bit depending on your machine).

安装nunit 2.6.4并通过nunit运行项目

Install nunit 2.6.4 and run the project via nunit

Visual Studio 2013

Visual Studio 2013

下载将于 1/3 到期

Download will expires 1/3

推荐答案

在你的 main.cs 中你需要添加一行.

In your main.cs you need to add one line.

[Test]
public void Test_MyPage()
{
    LoginPageObject objLogin = new LoginPageObject();
    FunctionTest cc = objLogin.FunctionAbcTest();
    FunctionTest objAbcTest = new FunctionTest();
    objAbcTest.SpeedTest();
}

还将您的 Xpath 更改为

Also change your Xpath to

 [FindsBy(How = How.XPath, Using = "//div[@id='cssmenu']/ul/li[3]/a/span")]
 public IWebElement UserForm { get; set;}

这将解决您的问题.

而且我认为您选择的站点是作为示例来说明您的功能为何不起作用.可能,您的原始站点 ID 不同.而且好像不是作业.

And I think the site you have chosen is to use as an example to show why your function is not working. Probably, your original site id different. And it does not seems to be homework.

请让我们知道它是否有效.

Please do let us know whether it worked or not.

祝您编写进一步代码的脚本好运.

Best of Luck in scripting your further code.

这篇关于C# 无法返回到我的另一个类文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆