我使用此代码下载文件,但它不起作用
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("browser.download.dir","D:\\WebDriverDownloads");
profile.setPreference("browser.download.folderList", 2);
profile.setPreference("browser.helperApps.neverAsk.saveToDisk","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;");
profile.setPreference( "browser.download.manager.showWhenStarting",false );
profile.setPreference( "pdfjs.disabled",true );
FirefoxDriver driver = new FirefoxDriver(profile); //Shows error on this line
driver.get("http://toolsqa.com/automation-practice-form/");
driver.findElement(By.linkText("Test File to Download")).click();
Thread.sleep(5000);
Run Code Online (Sandbox Code Playgroud)
它给了我错误
当我删除时
'轮廓'
形成此FirefoxDriver driver = new FirefoxDriver(profile);
代码,然后代码成功运行,但下载文件窗口未关闭,文件也未下载。
我使用机器人代替这个
Robot object=new Robot();
object.keyPress(KeyEvent.VK_DOWN);
object.keyRelease(KeyEvent.VK_DOWN);
object.keyPress(KeyEvent.VK_ENTER);
object.keyRelease(KeyEvent.VK_ENTER);
Run Code Online (Sandbox Code Playgroud)
它工作正常。但是为什么我上面的代码不起作用?
我在春季启动时使用 MongoDBRepository,当我在数据库中保存一些对象时,一切正常。但是当我通过 id 找到对象时,spring 不允许这样做。
我尝试将 VehicleRoutingProblemSolution 类型更改为 Object 类型,但是 VehicleRoutingProblemSolution 具有其他对象字段 PickupService 并且它没有默认构造函数。是的,这个类是不可变的......我无法创建默认构造函数,我该怎么办?
import com.fasterxml.jackson.annotation.JsonProperty;
import com.graphhopper.jsprit.core.problem.solution.VehicleRoutingProblemSolution;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
@Document(collection = "vrp_solutions")
public class VrpSolutionHolder {
// Specifies the solution id
@Id
@JsonProperty("id")
private String id;
// Specifies the solution id
@JsonProperty("solution")
private VehicleRoutingProblemSolution vehicleRoutingProblemSolution;
// Created at timestamp in millis
@JsonProperty("created_at")
private Long created_at = System.currentTimeMillis();
public VrpSolutionHolder(String id, VehicleRoutingProblemSolution vehicleRoutingProblemSolution) {
this.id = id;
this.vehicleRoutingProblemSolution = vehicleRoutingProblemSolution;
}
public String getId() {
return id;
} …
Run Code Online (Sandbox Code Playgroud) 我使用下面的代码,但它在句子icount = cmd.ExecuteNonQuery上给出了错误
cn.Open()
str = "SELECT [srno],[caste]FROM [SchoolERP].[dbo].[caste] where (caste ='" + (TextBox1.Text) + "')"
cmd = New SqlCommand(str, cn)
dr1 = cmd.ExecuteReader()
If Not dr1.HasRows Then
str = "INSERT INTO [SchoolERP].[dbo].[caste]([caste])VALUES('" + TextBox1.Text + "')"
cmd = New SqlCommand(str, cn)
icount = cmd.ExecuteNonQuery
MessageBox.Show(icount)
Else
MsgBox("Record Exists")
cn.Dispose()
End If
cn.Close()
Run Code Online (Sandbox Code Playgroud)