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>
PDHide
11.1k2 gold badges17 silver badges43 bronze badges
asked Jan 14, 2020 at 11:45
2
  • Hi which language is this ? you have to use selenium localization Commented Jan 14, 2020 at 12:32
  • Please mention the locale language your using, and programming language Commented Jan 14, 2020 at 12:33

1 Answer 1

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]")
answered Jan 14, 2020 at 13:51
5
  • 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? Commented Jan 14, 2020 at 18:10
  • You should add a wait , try adding 10 sec wait before clicking and see if it works . Commented Jan 14, 2020 at 18:18
  • solved thanks!!. i detected the element by copying the xpath and not by class. thanks a lot! Commented Jan 14, 2020 at 18:22
  • @Yemi please accept the answe Commented Jan 14, 2020 at 18:31
  • Could you accept the answer by clicking the tick sign near to my answer (near to my upvote button) @Yemi Commented Feb 10, 2020 at 18:30

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.