我有自己构建的自动化服务,在运行自动化之前,你给它一个链接,所以当你启动自动化时,你首先会重定向到这个链接。
在我的机器上,您可以完美地重定向,但在朋友计算机上,Firefox浏览器已打开,就是这样。
有谁知道可能是什么问题?
这是负责此事的类:
case class csvUploadData(clientUrl: String)
val csvUploadForm = Form(
mapping(
"clientUrl" -> nonEmptyText)(csvUploadData.apply)(csvUploadData.unapply))
def uploadCSV = Action.async(parse.multipartFormData) { implicit request =>
csvUploadForm.bindFromRequest.fold(
formWithErrors => {
Future {
Redirect(routes.Application.index).flashing(
"error" -> formWithErrors.error("clientUrl").get.message)
}
},
userData => {
request.body.file("csvFile").fold(Future {
Redirect(routes.Application.index).flashing(
"error" -> "Missing CSV file").withSession(request.session)
}) { formFile =>
import java.io.File
val filename = formFile.filename
Future {
val file = formFile.ref.file
val purchaseInfos = purchaseDS(file)
val t = Try {
val driver: WebDriver = new FirefoxDriver
val actions: ActionsHMRC = new ActionsHMRC(driver, userData.clientUrl)
val results = actions.insertData(purchaseInfos)
results.filter(_._2.isFailure)
}
t match {
case Success(failures) =>
val failedMsg = if (failures.nonEmpty)
failures.map{case (pi, err) => s"${pi.invoiceNumber} -> ${err}}"}.mkString("The following rows failed: [\n","\n","\n\n\n]")
else ""
Redirect(routes.Application.index).flashing(
"success" -> s"The file '$filename' automation successfuly.\n$failedMsg")
case Failure(e) =>
println(e)
Redirect(routes.Application.index).flashing (
"error" -> s"The file '$filename' automation failed.")
}
}
}
})
}
}
我有42.0,他有43.0.4
答案 0 :(得分:2)
我认为这是因为Mozilla firefox的最新更新出现了新问题。
它也和我一起发生。
要解决此问题,您需要将setPreference设置为xpinstall.signatures.required", false
到firefox配置文件,然后将其传递给驱动程序对象
firefoxProfile.setPreference("xpinstall.signatures.required", false);
以下代码适用于旧的硒罐。
static WebDriver driver=null;
public static void main(String[] args) {
final FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("xpinstall.signatures.required", false);
driver = new FirefoxDriver(firefoxProfile);
driver.get("https://www.google.de/");
非常感谢,但有一项更改FirefoxDriver(firefoxProfile)
无效。相反,FirefoxOptions如下:
final FirefoxProfile firefoxProfile = new FirefoxProfile();
firefoxProfile.setPreference("xpinstall.signatures.required", false);
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setProfile(firefoxProfile);
driver = new FirefoxDriver(firefoxOptions);