Issue
Please suggest way to click on - Facebook sign up page- CREATE NEW ACCOUNT BUTTON- using selenium java ( Right click is not permitted) I tried using this code-- https://www.facebook.com/--
WebElement element=driver.findElement(By.id("u_0_2_1a"));
JavascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("arguments[0].click();", element);
Error: org.openqa.selenium.NoSuchElementException:
no such element: Unable to locate element: {"method":"css selector","selector":"#u_0_2_1a"}
Solution
You are using the ID
attribute which can change. Hence its throwing no such element. Please use the xpath as below:
//form//a[@role='button'][contains(.,'Create New Account')]
I just tested it. it works. Below should be your code.
WebElement element=driver.findElement(By.xpath("//form//a[@role='button'][contains(.,'Create New Account')]"));
Answered By - Sonali Das
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.