Java 正在尝试在facebook上载照片,但无法单击上载照片链接

Java 正在尝试在facebook上载照片,但无法单击上载照片链接,java,selenium,webdriver,Java,Selenium,Webdriver,正在尝试在facebook上载照片,但无法单击上载照片链接 my_profile.changePicture(“E:\my Documents\Desktop”) 公共类MyProfilePage扩展页面{ public void changePicture(String filepath) { try { Thread.sleep(9000); } catch (InterruptedException e) { // TODO Auto-gen

正在尝试在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文件中


上传图片=//a[@data action type='upload\u photo']/div/input[@type='file'][@class='n'u 5f0v'][@title='Choose a file to upload']][contains(@id,'js')]

这是模式弹出窗口,您必须先切换到它,然后才能找到链接

driver.switchTo().activeElement()

@suhail您是否尝试在输入元素上简单地使用sendKeys而不单击它?作为sendKeys的值,请使用文件的路径