0

there is a website and profiles are listed with their profile photos. Like this

I'm trying to get href of that profile photos (i'm not trying to get href of photo, i'm trying to profile href). So i need to get element under the mouse cursor. There is simple code for do it in basic c# browser: Link but i'm using Selenium driver so i think i need to do it by executing JavaScript. So i've found that thread for using elementfrompoint with javascript on selenium but it returns me "null" enter link description here

Here is the class of that profile photos. Class I'm trying to get href "/en/community/ProfileUrlHere"

Edit: i've tried to use

ele = (IWebElement)((IJavaScriptExecutor)driver).ExecuteScript(
                    "return document.elementFromPoint(arguments[0], arguments[1])", 
                    Cursor.Position.X, Cursor.Position.Y);

But it returns null seems like i've problems with coordinates, "Cursor.Position.X, Cursor.Position.Y" i need to get coordinates by using "event.ClientX"

              String s_Script = "var X, Y; "
              
               + "  X = event.clientX; "
               + "  Y = event.clientY; "
               + " alert(X);"
                + "return new Array(X, Y);";

But i get "OpenQA.Selenium.WebDriverException: 'javascript error: Cannot read property 'clientX' of undefined" this error.

Jiri Janous
  • 1,189
  • 1
  • 6
  • 14
JustForss
  • 17
  • 4

1 Answers1

-1

i've tried to use

ele = (IWebElement)((IJavaScriptExecutor)driver).ExecuteScript(
                "return document.elementFromPoint(arguments[0], arguments[1])", 
                Cursor.Position.X, Cursor.Position.Y);

But it returns null seems like i've problems with coordinates, "Cursor.Position.X, Cursor.Position.Y" i need to get coordinates by using "event.ClientX"

But i get "OpenQA.Selenium.WebDriverException: 'javascript error: Cannot read property 'clientX' of undefined" this error.

JustForss
  • 17
  • 4