ENV Selenium 3.141 C# Chrome webdriver
I want to select an item in a "selection mode" where if I click on a up-left point and down-right point around the item, I get a square around the item and the item gets selected.
This is my code:
IWebElement item = driver.FindElement(By.XPath("//div[@title='item_to_select']"));
Actions actions = new Actions(driver);
actions.MoveToElement(item, 100, 100).Click().Perform();
System.Threading.Thread.Sleep(10000);
actions.MoveToElement(item, -100, -100).Click().Perform();
System.Threading.Thread.Sleep(10000);
When debugging and stepping over every line, I find that Selenium performs the first click, then when it gets to the second, it somehow loses the first click, and then clicks on the second point. I tried to "trick" it by adding another actions.MoveToElement(item, 400, 400).Click().Perform(); and I got the item selected, but the code failed.
Any idea of why it does this?
SOLVED
I solved creating multiple Action elements.
Actions action1 = new Actions(driver);
Actions action2 = new Actions(driver);
action1 .MoveToElement(item, 100, 100).Click().Perform();
System.Threading.Thread.Sleep(10000);
action2 .MoveToElement(item, -100, -100).Click().Perform();
System.Threading.Thread.Sleep(10000);