Reputation: 7
BasicConfigurator.configure();
System.setProperty("webdriver.chrome.driver","C:\\Users\\Piotrek\\projekciki\\src\\main\\java\\selenium\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get("https://twitter.com/login?lang=pl");
WebElement element = driver.findElement(By.xpath("/html/body/div/div/div/div[2]/main/div/div/form/div/div[1]/label/div/div[2]/div/input"));
element.sendKeys("LOGIN");
just opening twitter and doing nothing. where is the problem?
Upvotes: 0
Views: 46
Reputation: 1166
Modified code
BasicConfigurator.configure(); System.setProperty("webdriver.chrome.driver","C:\\Users\\Piotrek\\projekciki\\src\\main\\java\\selenium\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.navigate("https://twitter.com/login?lang=pl");
WebDriverWait wait = new WebDriverWait(driver, 10);
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[contains(@name,'username_or_email')]")));
WebElement element = driver.findElement(By.xpath("//input[contains(@name,'username_or_email')]"));
element.sendKeys("LOGIN");
if above xpath doesn't work use this one-//input[contains(@name,'username_or_email' )and (@type='text')]
Upvotes: 1