Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Selenium webdriver 如何配合fitnesse使用硒_Selenium Webdriver_Fitnesse_Selenium Fitnesse Bridge - Fatal编程技术网

Selenium webdriver 如何配合fitnesse使用硒

Selenium webdriver 如何配合fitnesse使用硒,selenium-webdriver,fitnesse,selenium-fitnesse-bridge,Selenium Webdriver,Fitnesse,Selenium Fitnesse Bridge,我正在创建一个小测试。在代码隐藏中,我有两个类。页面,登录页面。 第一部分是运行。我不知道如何与第二部分整合。目前我可以打开浏览器。我还尝试使用PageObect模型模式 Fitnesse code !|import| |TestFramework| !|script|Pages| |Goto||https://gmail.com| |LoginPage|CheckRequiredElementsPresent|Pass| Fixtures pu

我正在创建一个小测试。在代码隐藏中,我有两个类。页面,登录页面。 第一部分是运行。我不知道如何与第二部分整合。目前我可以打开浏览器。我还尝试使用PageObect模型模式

Fitnesse code
    !|import|
    |TestFramework|

    !|script|Pages|
    |Goto||https://gmail.com|
    |LoginPage|CheckRequiredElementsPresent|Pass|


Fixtures 

public class Pages 
{
   string url;
   private LoginPage loginPage;

   public static void Goto(string url)
   {
       Browser.Goto(url);
   }
}


public class LoginPage 
{

    static string PageTitle;

    [FindsBy(How = How.Id, Using = "TextUsername")]
    private static IWebElement username;

    [FindsBy(How = How.Id, Using = "TextPassword")]
    private static  IWebElement password;

    [FindsBy(How = How.Id, Using = "_ButtonLogin")]
    private static IWebElement submit;

    public string IsAtLoginPage()
    {
        return "";
    }
    public string CheckRequiredElementsPresent()
    {            

        if (username != null && password != null && submit != null)
        {
            return "Pass";
        }
        return "Fail";
    }

}

}您需要执行以下操作:

Fitnesse代码 !|进口| |测试框架| !|脚本|页| |后藤||https://gmail.com| |检查所需元素|通过| 您需要从Pages类调用第二个类,请查看我所做的代码更改和fitnesse fixture更改

固定设施 公共类页面 { 字符串url; 私人登录页面登录页面; 公共静态void Goto(字符串url) { Goto(url); } //这是引用第二类方法所需要做的。 //此方法将按顺序在Goto方法之后调用。 公共布尔值checkRequiredElement(){ return loginPage.CheckRequiredElementsPresent()返回登录页 } }
您没有在fitnesse fixture中为第二个类添加任何引用。我只是修改了代码。但是找不到方法CheckrequiredElementsPresentcheck下面的答案。不过这里混合了Java和C。 !|import| |TestFramework| !|script|Pages| |Goto||https://gmail.com| |check Required Element|Pass| public class Pages { string url; private LoginPage loginPage; public static void Goto(string url) { Browser.Goto(url); } // This is what you need to do to refer method of second class. // This method will be called after Goto method in sequence. public boolean checkRequiredElement(){ return loginPage.CheckRequiredElementsPresent() } }