I have copied the following html code snippet from the link – https://en.wikipedia.org/w/index.php?title=Special:CreateAccount&returnto=Form
Here input is a tag and id is an attribute with value=wpEmail.
It indicates a text box for email input. We shall go to the text box and write the email address there.
To do the same we shall use the following xpath path locator technique.
driver.findElement(By.xpath("//input[@id='wpEmail']")).sendKeys("abc@abc.com");
This is an example of relative xpath. Check the syntax carefully.
//tagname[@attributename=’attribute value’]
driver.findElement(By.xpath("//tagname[@attributename='attribute value']")).supportedMethod();
Make sure to replace ‘tagname‘, ‘attributename’, and ‘attribute value‘ with the actual values you are looking for in your HTML document.
In the above code, we first locate the element using driver.findElement(By.xpath()). Then, we can perform any method supported by the WebElement class on the element. In this example, I used supportedMethod() as a placeholder. You should replace it with the actual method you want to perform on the found element.
For example, if you want to click the element, you would use .click(). Adjust the method according to your requirements.