I try to write in the text field using selenium but an error has occurred"unexpected identifier " w any help enter image description here
I am not sure what selector you are using, but if it is the same input tag as visible in your snapshot then you can try the below code. [it is just a blind attempt].
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.name("firstname"))).sendKeys("whatever");
and in general, you can also use the below code.
driver.findElement(By.name("firstname")).sendKeys("Whatever");
I believe you can take help from this thread - Selenium Webdriver: Entering text into text field
Below is the full working code. for demonstration, I have only filled firstname and secondname. do like the ans if it helps.
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
import java.util.concurrent.TimeUnit;
public class Testing {
public static void main(String[] args) {
WebDriver driver = new ChromeDriver();
WebDriverWait wait = new WebDriverWait(driver, 30);
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
driver.manage().window().maximize();
String myurl = "https://www.phptravels.net/register";
driver.get(myurl);
WebElement FirstName = wait.until(ExpectedConditions.visibilityOfElementLocated
(By.xpath("//input[@name=\"firstname\"]")));
FirstName.sendKeys("Dina");
WebElement LastName = wait.until(ExpectedConditions.visibilityOfElementLocated
(By.xpath("//input[@name=\"lastname\"]")));
LastName.sendKeys("Hayden");
System.out.println("Successfully Enter Value in the textbox.");
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.