enter image description here尝试在Facebook中上传照片,但无法单击上传照片链接
my_profile.changePicture(“ E:\ My Documents \ Desktop”);
公共类MyProfilePage扩展了页面{
public void changePicture(String filepath) {
try {
Thread.sleep(9000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
click("profile_picture");
try {
Thread.sleep(9000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
click("upload_picture");
type("upload_picture", filepath);
}
Xpath存储在config.properties文件中。
upload_picture = // a [@ data-action-type ='upload_photo'] / div / input [@ type ='file'] [@ class ='_ n _5f0v'] [@ title ='选择一个文件上传'] [包含(@ id,'js')]
答案 0 :(得分:0)
这是模式弹出窗口,您必须先切换到它,然后才能找到链接。
driver.switchTo().activeElement()
答案 1 :(得分:0)
@suhail您是否尝试仅在输入元素上使用sendKeys而不单击它?作为sendKeys的值,请使用文件的路径。