Facebook upload a picture using selenium webdriver



  • Using Selenium WebDriver I'm not able to click on add picture/video to a group in Facebook.

    i tried

        driver.findElement(By.xpath("//*[@aria-label='הוסף תמונה או סרטון']")).click();
    

    but it does not work.

    I'm getting the error "Cannot click elements"

    How do I locate the element?

    The html snippet is:

    <div class="_3jk">
        <input aria-label="הוסף תמונה או סרטון" accept="video/*,  video/x-m4v, video/webm, video/x-ms-wmv, video/x-msvideo, video/3gpp, video/flv, video/x-flv, video/mp4, video/quicktime, video/mpeg, video/ogv, .ts, .mkv, image/*, image/heic, image/heif" containerclassname="_5g_r" multiple="" name="composer_photo[]" display="inline" role="button" tabindex="0" data-testid="media-sprout" type="file" class="_n _5f0v" id="js_14">
    </div>
    


  • Hi you could try converting the local text to Unicode values first, use the below website to do that:

    https://www.branah.com/unicode-converter

    So the unicode character for :

    הוסף תמונה או סרטון is

    \u05d4\u05d5\u05e1\u05e3 \u05ea\u05de\u05d5\u05e0\u05d4 \u05d0\u05d5 \u05e1\u05e8\u05d8\u05d5\u05df
    

    Now use that value in your xpath:

    a=driver.findElement(By.xpath("//*[@aria-label='\u05d4\u05d5\u05e1\u05e3 \u05ea\u05de\u05d5\u05e0\u05d4 \u05d0\u05d5 \u05e1\u05e8\u05d8\u05d5\u05df']"));
    

    But still your code won't work

    You are trying to click an input element , you should click the div element . Click won't work in input element.

    Try using below locator:

    by.xpath("(//*[@class=\"_3jk\"])[1]")
    

Log in to reply
 

Suggested Topics