I am getting this error "Missing or invalid type argument for pointer action" while trying to execute the below code for Selenium in Java.
public static void main(String args[]) throws InterruptedException
{
WebDriver driver = new FirefoxDriver();
driver.get("https://www.flipkart.com/");
driver.findElement(By.xpath(".//*[@class='_3Ji-EC']/li[8]/a")).click();
WebElement elem = driver.findElement(By.className("_2zrpKA"));
elem.sendKeys("ABC");
WebElement elem2 = driver.findElement(By.xpath(".//*[@class='_2zrpKA
_3v41xv']"));
elem2.sendKeys("XYZ");
driver.findElement(By.xpath(".//*[@class='_2AkmmA _1LctnI
_7UHT_c']")).click();
System.out.println("Success");
//driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Thread.sleep(5000);
WebElement elem3 = driver.findElement(By.xpath(".//*[@class='_3Ji-
EC']/li[7]/a"));
System.out.println("success");
Actions action = new Actions(driver);
action.moveToElement(elem3).build().perform();
driver.findElement(By.xpath(".//*[@class='_1u5ANM']/li[9]/a")).click();
}
I have tried this using Selenium 3.4.0 and Firefox 51.x, 52.x, 53.x with the latest geckodriver 16.1 and 16.0 . When I used Firefox 53.x, I was getting the error "Expected [object Undefined] undefined to be a string" else every time I am getting the error "Missing or invalid type argument for pointer action".
In the above code I am able to get "success" printed 2nd time without any problem but after that I am getting the error.
Here is the solution to your Question:
To work with
Selenium 3.4.0
withgeckodriver v0.16.1
& Mozilla Firefox 53.x you need to specify the absolute path of thegeckodriver
in your code as:Your xpath seems petty vulnerable to me. You may want to construct more unique logical xpath. To click on
Log In
button you may do:I would suggest you not to rely only on class, append some more properties. The xpath for
Enter Email
field can be:The xpath for
Enter Password
is not unique, you may like to change it to:The xpath for the
Login
button needs to be unique as follows:Avoid using
Thread.sleep(5000);
rather useImplicitlyWait
orExplicitWait
The xpath to click on the Username is again vulnerable, you may like to change it to:
The xpath to click the
Log Out
button is again vulnerable, you may like to change it to:Here is your own working code block with some simple tweaks;
Let me know if this Answers your Question.