I am very new to Selenium. Basically i need to populate the fields below using selenium web-driver in Visual Studio. Because of the lightning components i am having trouble using XPath. Need help resolving this issue

I tried finding the element and also by using the XPath with the code below but with no luck:

driver.FindElement(By.Name("First Name")).Click();


enter image description here

  • 1
    What have you tried so far? Where are you stuck? Please edit your question, and take a moment to read How to Ask.
    – David Reed
    May 8, 2019 at 17:41

1 Answer 1


Use the below XPATHs for identifying the fields:

String fnameXpath  = "//label[span[text()='First Name']]/following-sibling::input";

driver.findElement(By.xpath(fnameXpath)).sendKeys("First Name");

Similarly, update the above XPath with the right text of the field then you will be able to Identify other fields as well.

For example: For Last Name:

String lnameXpath  = "//label[span[text()='Last Name']]/following-sibling::input";

String emailXpath  = "//label[span[text()='Email']]/following-sibling::input";

String phoneXpath  = "//label[span[text()='Phone']]/following-sibling::input";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.