Hello,
I am using the CefSharp webbrowser control. I will explain what I am trying to do:
I load in the URL: "https://uniswapv3.flipsidecrypto.com"
I find the control which is a SLIDER handle by classname "irs-handle from" successfully! (See red arrow in the image below)
I now find the X and Y coordinate for this SLIDER successfully!
Now I want to simulate a MouseLeftDown click on this X and Y coordinate, --- and DRAG this SLIDER to the right a bit by calling the MouseLeftUp event with a new X coordinate.
When executing the code. This SLIDER is actually clicked on because the slider changes value a bit. So this part is successful. But it seems that the MouseLeftUp event with the new X coordinate doesn't release the slider to the right.
This is the slider I am trying to move in the URL (The round green handle, - where the red arrow(1,773) in the image below in pointing to)
(As seen in the end of the post I have posted an image of the MouseLeftDown/MouseLeftUp events. Somehow the website will not post the question if I post that code as it is)
I wonder what I could be missing. It has to be a minor detail missing? This is how I try to drag the slider to the right: (+5 to +100)
//Now click and drag slider to the right
MouseLeftDown(int.Parse(coordx) + 5, int.Parse(coordy) + 5);
MouseLeftUp(int.Parse(coordx) + 100, int.Parse(coordy) + 5);
Thank you!
private void button1_Click(object sender, EventArgs e) { new Thread(moveSlideControl).Start(); }
void moveSlideControl()
{
var scriptTask = browser.EvaluateScriptAsync(@"
var play = document.getElementsByClassName('irs-handle from')[0]
function findPos(obj)
{
var curleft = 0;
var curtop = 0;
if (obj.offsetParent)
{
do
{
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
} while (obj = obj.offsetParent);
return { X: curleft,Y: curtop};
}
}
findPos(play)"
).ContinueWith(x =>
{
// 2. Continue with finding the coordinates and using MouseClick method
// for pressing left mouse button down and releasing it at desired end position.
var responseForMouseClick = x.Result;
if (responseForMouseClick.Success && responseForMouseClick.Result != null)
{
var xy = responseForMouseClick.Result;
var json = JsonConvert.SerializeObject(xy).ToString();
var coordx = json.Substring(json.IndexOf(':') + 1, 3);
var coordy = json.Substring(json.LastIndexOf(':') + 1, 3);
//Now click and drag slider to the right
MouseLeftDown(int.Parse(coordx) + 5, int.Parse(coordy) + 5);
MouseLeftUp(int.Parse(coordx) + 100, int.Parse(coordy) + 5);
}
});


