在testNG.xml中传递的参数

时间:2018-08-18 09:43:50

标签: testng

我已经为登录Yahoo编写了以下代码: 公共类ParametersTestClass {

WebDriver driver;

@Test
@Parameters({"url","emailId"})
    public void YohaooLoginTest(String url,String emailId)
{
    System.setProperty("webdriver.chrome.driver","C:\\Users\\Ankita Jaiswal\\Downloads\\SETUPS\\chromedriver.exe");
    driver=new ChromeDriver();
    driver.get(url);
    driver.findElement(By.xpath("//*[@id='uh-signin']")).click();  //why it was not working?

    driver.findElement(By.xpath("//*[@id='login-username']")).sendKeys(emailId);
    driver.findElement(By.xpath("//*[@id='login-signin']")).click();

}
}

并在testNG.xml中传递了url和emailID参数的值,但是在执行时,它没有单击“登录”按钮。

在评论“登录”按钮时,它可以正常工作。 有人可以帮我吗?

1 个答案:

答案 0 :(得分:0)

您可以尝试使用Action类或JavaScriptExecutor单击它,

guard let image = selectedImage else {
        return
    }

    let heightInPixels = Int(image.size.height * image.scale)
    let widthInPixels = Int(image.size.width * image.scale)



     let parameters: Parameters = ["user_id":  Utility().getBearerToken(),"description": descriptionTextView.text ?? "",
     "lat": self.lat ?? "" , "long":self.long ?? "" ,
     "location_name": locationTextView.text ?? "" ,
     "height": heightInPixels, "width": widthInPixels];


//    let parameters: Parameters = ["user_id":  Utility().getBearerToken()];
    print(parameters)
    Alamofire.upload(multipartFormData: { MultipartFormData in
        for (key, value) in parameters {
            MultipartFormData.append(((value as AnyObject).data(using: String.Encoding.utf8.rawValue))!, withName: key)

        }

        let imgData = UIImageJPEGRepresentation(image,1)
        MultipartFormData.append(imgData!, withName: "file", fileName: "upload.jpg", mimeType: "image/jpeg")

    }, to: "http://server.com/upload.php") { (result) in
        switch result {
        case .success(let upload, _, _):
            upload.uploadProgress(closure: { (Progress) in
                print("Upload Progress: \(Progress.fractionCompleted)")
            })

            upload.responseString { response in
                print(response.result.value!)
            }       
        case .failure(let encodingError):
            print(encodingError.localizedDescription)
            break
        }
  }

OR

MultipartFormData.append(value.data(using: .utf8)!, withName: name!)