1

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 which language is this ? you have to use selenium localization – PDHide Jan 14 at 12:32
  • Please mention the locale language your using, and programming language – PDHide Jan 14 at 12:33
3

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]")
  • thanks, but it's still does not work. getting exception: Element <div class="_3jk"> is not clickable at point (633,238) because another element <div class="_3u15"> obscures it. any other ideas? – Yemi Jan 14 at 18:10
  • You should add a wait , try adding 10 sec wait before clicking and see if it works . – PDHide Jan 14 at 18:18
  • solved thanks!!. i detected the element by copying the xpath and not by class. thanks a lot! – Yemi Jan 14 at 18:22
  • @Yemi please accept the answe – PDHide Jan 14 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.