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 localizationPDHide– PDHide2020年01月14日 12:32:45 +00:00Commented Jan 14, 2020 at 12:32
-
Please mention the locale language your using, and programming languagePDHide– PDHide2020年01月14日 12:33:37 +00:00Commented Jan 14, 2020 at 12:33
1 Answer 1
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– Yemi2020年01月14日 18:10:13 +00:00Commented Jan 14, 2020 at 18:10
-
You should add a wait , try adding 10 sec wait before clicking and see if it works .PDHide– PDHide2020年01月14日 18:18:50 +00:00Commented Jan 14, 2020 at 18:18
-
solved thanks!!. i detected the element by copying the xpath and not by class. thanks a lot!Yemi– Yemi2020年01月14日 18:22:19 +00:00Commented Jan 14, 2020 at 18:22
-
@Yemi please accept the answePDHide– PDHide2020年01月14日 18:31:48 +00:00Commented 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) @YemiPDHide– PDHide2020年02月10日 18:30:54 +00:00Commented Feb 10, 2020 at 18:30