Click the selenium Java button
•
Java
I have a button:
<input type="button" onclick="onOpenSessionClick()" value="Open device access">
But when I execute the command:
driver.findElement(By.xpath("//input[@value='Open access device' and @type='submit']")).click();
Click No This is my code:
if (isElementPresent((By.xpath("//input[@value='Open device access']"))))
{
Sy@R_403_2354@.out.println("Je suis dans le if");
Thread.sleep(2000);
driver.findElement(By.xpath("//input[@value='Open device access' and @type='submit']")).click();
Sy@R_403_2354@.out.println("Je suis dans le if et jai open");
Thread.sleep(5000);
assertTrue(isElementPresent(By.xpath("/html/body/div[2]/div[3]/div[3]/div[2]/div/div[2]/div[2]/div/div[6]/div/div/div/p/span")));
assertTrue(isElementPresent(By.xpath("/html/body/div[2]/div[3]/div[3]/div[2]/div/div[2]/div[2]/div/div[6]/div/div/div[2]/input")));
assertTrue(isElementPresent(By.xpath("/html/body/div[2]/div[3]/div[3]/div[2]/div/div[2]/div[2]/div/div[6]/div/div/div[2]/input[2]")));
Sy@R_403_2354@.out.println("Je suis dans le if et je cherche");
}
Solution
In your case, the input is a button, not a submit
Try this / / enter [@ value = 'open device access'] or / / enter [@ value =' open device access' and @ type = 'button']
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码
