Selenium | How to locate an element with css selector and set value in it using code

| By Webner

See the image below and html source of it. There is an element with name “email”. If we want to access that field and set a value in it, we can achieve that with this sample code:

public void test()
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS); driver.findElement(By.cssSelector("input[name='email']")).sendKeys("");//set value in the textfield

Webner Solutions is a Software Development company focused on developing CRM apps (Salesforce, Zoho), LMS Apps (Moodle/Totara), Websites and Mobile apps. If you need any software development assistance please contact us at

Leave a Reply

Your email address will not be published. Required fields are marked *