0

我正在尝试让 selenium webdriver 来测试此代码,但我收到此错误,是因为我使用 Test NG 而不是 public static main 将其作为@Test 运行吗?:

org.testng.TestNGException:

方法 PopulateBorrowerPresentAddress 需要 1 个参数,但在 @Test 注释中提供了 0。

package testautomation;

import static org.testng.AssertJUnit.assertTrue;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebDriverBackedSelenium;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;

import com.thoughtworks.selenium.Selenium;

public class BorrowerInformation  {

    static WebDriver driver;

    static Selenium selenium;
    //Base Element Names
    //Anything multiple parts of this class might use
    //or other stuff that other classes will use but belongs to this class
    static String FormBase = "viewModel.MortgageForm.";
    static String BorrowerInformationBase = FormBase + "BorrowerInformationSection.";
    static String PrimaryBorrowerBase = BorrowerInformationBase + "Borrowers[0]";
    static String PresentAddressElementName = ".PresentAddress";

    static String AddressElementName=".Address";
    static String BorrowerFirstNameElement = "_FirstName";
    static String BorrowerLastNameElement = "_LastName";
    static String BorrowerSuffixElement ="_Suffix";
    static String BorrowerSocialSecurityNumberElement= ".SocialSecurityNumber";
    static String BorrowerHomePhoneNumberElement= ".HomePhoneNumber";
    static String BorrowerYearsInSchoolElement= ".YearsInSchool";
    static String BorrowerMarriageStatusElement=".MarriageStatus";

    static String FormBase1 = "viewModel_MortgageForm_";
    static String BorrowerInformationBase1 = FormBase + "BorrowerInformationSection_";
    static String PrimaryBorrowerBase1 = BorrowerInformationBase1 + "Borrowers_1_";

    static String AddressLine1 = ".AddressLine1";
    static String AddressLine2 = ".AddressLine2";
    static String City = ".City";
    static String State = ".State";
    static String Zip= ".Zip";
    static String MailingAddressElementName = ".MailingAddress";
    static String MailingAddressSummaryElementName =  ".AddressSummary";
    static String FormerAddressElementName = ".FormerAddress";

    static String FormerAddressBase = PrimaryBorrowerBase+ FormerAddressElementName+AddressElementName;
    static String PresentAddressBase = PrimaryBorrowerBase+PresentAddressElementName+AddressElementName;

    static String MailingAddressBase = PrimaryBorrowerBase+ MailingAddressElementName;


    private static  Map<String,String> PrimaryBorrowerInputDictionary;
    static {
        Map<String,String> map = new HashMap<String, String>();
        map.put(BorrowerFirstNameElement,"Alex");
        map.put(BorrowerLastNameElement,"Holmes");
        map.put(BorrowerSuffixElement,"Mr.");
        map.put(BorrowerSocialSecurityNumberElement,"327-34-1869");
        map.put(BorrowerLastNameElement,"Holmes");
        map.put(BorrowerSocialSecurityNumberElement,"327-34-1869");
        map.put(BorrowerHomePhoneNumberElement,"773-223-23232");
        map.put(BorrowerYearsInSchoolElement,"5");

    }
    private static Map<String,String> PrimaryBorrowerPresentAddressDictionary;
    static {
        Map<String,String> map1 = new HashMap<String, String>();
        map1.put(AddressLine1,"2031 N. Harlem Ave");
        map1.put(AddressLine2,"2S");
        map1.put(City,"Chicago");
        map1.put(State,"IL");
        map1.put(Zip,"60707");
    }

    private static  Map<String,String> PrimaryBorrowerMailingAddressDictionary;
    static {
        Map<String,String> map2 = new HashMap<String, String>();
        map2.put(AddressLine1,"5840 W. Rice");
        map2.put(AddressLine2,"4S");
        map2.put(City,"Chicago");
        map2.put(State,"IL");
        map2.put(Zip,"60651");
    }

private static  Map<String,String> PrimaryBorrowerFormerAddressDictionary;
static {
    Map<String,String> map3 = new HashMap<String, String>();
    map3.put(AddressLine1,"351 S. Harvey St");
    map3.put(AddressLine2,"2A");
    map3.put(City,"Oak Park");
    map3.put(State,"IL");
    map3.put(Zip,"60707");
}

    @Test
public static void PopulateBorrower(String PrimaryBorrowerBaseName1,String
PrimaryBorrowerBaseName)
    {       String fName= PrimaryBorrowerInputDictionary.get(BorrowerFirstNameElement);
            String lName=PrimaryBorrowerInputDictionary.get(BorrowerLastNameElement);
            String suffix=PrimaryBorrowerInputDictionary.get(BorrowerSuffixElement);
            String social=PrimaryBorrowerInputDictionary.get(BorrowerSocialSecurityNumberElement);
            String homePhone=PrimaryBorrowerInputDictionary.get(BorrowerHomePhoneNumberElement);
            String schoolYears=PrimaryBorrowerInputDictionary.get(BorrowerYearsInSchoolElement);

        driver.findElement(By.id(PrimaryBorrowerBaseName1 + BorrowerFirstNameElement)).sendKeys(fName);
        driver.findElement(By.id(PrimaryBorrowerBaseName1 + BorrowerLastNameElement)).sendKeys(lName);
        driver.findElement(By.id(PrimaryBorrowerBaseName1 + BorrowerSuffixElement)).sendKeys(suffix);
        driver.findElement(By.name(PrimaryBorrowerBaseName + BorrowerHomePhoneNumberElement)).sendKeys(social);

        driver.findElement(By.name(PrimaryBorrowerBaseName + BorrowerHomePhoneNumberElement)).sendKeys(homePhone);
        driver.findElement(By.name(PrimaryBorrowerBaseName + BorrowerYearsInSchoolElement)).sendKeys(schoolYears);
        driver.findElement(By.name(PrimaryBorrowerBaseName +BorrowerMarriageStatusElement )).click();


        assertEquals(               
                driver.findElement(By.id(PrimaryBorrowerBaseName + BorrowerFirstNameElement))
                .getText(), fName);


        assertEquals(               
                driver.findElement(By.id(PrimaryBorrowerBaseName + BorrowerLastNameElement))
                .getText(), lName);


        assertEquals(               
                driver.findElement(By.id(PrimaryBorrowerBaseName + BorrowerSuffixElement))
                .getText(), suffix);


        assertEquals(               
                driver.findElement(By.id(PrimaryBorrowerBaseName + BorrowerHomePhoneNumberElement))
                .getText(), homePhone);

        assertEquals(               
                driver.findElement(By.id(PrimaryBorrowerBaseName + BorrowerYearsInSchoolElement))
                .getText(), schoolYears);

        assertTrue(             




            driver.findElement(By.id(PrimaryBorrowerBaseName + BorrowerMarriageStatusElement))
                .isSelected());

    }
4

0 回答 0