Error starting moveToElement () method in selenium webdriver?

I am new to selenium and when, I run below code for selenium webdriver in eclipse (java), but I get

"Exception in thread" main "org.openqa.selenium.UnsupportedCommandException: mouseMoveTo"

error?

WebDriver driver=new FirefoxDriver(); driver.get("http://newtours.demoaut.com/"); WebElement myElement=driver.findElement(By.cssSelector("input[name=userName]")); Actions myAction=new Actions(driver); myAction.moveToElement(myElement).click(). keyDown(myElement,keys.SHIFT).sendKeys(myElement,"test") .keysUp(myElement,keys.SHIFT). doubleClick(myElement) .contextClick().build().perform(); 

I want to run this code.

Thanks and Regards

+5
source share
3 answers

There is a known issue with the new version of FirefoxDriver, namely GeckoDriver, which does not support the Action class:

Selenium moveToElement (Actions) web driver error with puppet driver?

https://github.com/SeleniumHQ/selenium/issues/3348

Without further information, I assume this is also your problem. If you need to test FF, use an older version or Chrome with ChromeDriver

+5
source

Try this below xpath:

Explanation: Your input tag is the parent of the table tag so start the xpath with the table tag and then move forward using the following keywords for the input tag.

 driver.findElement(By.xpath("//table/../following::input[@name='userName']")).sendKeys("USERNAME"); 
+3
source

Explanation: Invalid cssSelector , use a single quote for the attribute value.

 driver.findElement(By.cssSelector("input[name='userName']")); 
+1
source

Source: https://habr.com/ru/post/1264880/


All Articles