2015-12-07 2 views
0

Я пытаюсь войти в систему, используя селен.Selenium Поиск элементов через xpath

<form id="main-login-form" class="login-form form-container"> 
<input  name="username" id="username-input" placeholder="Username" class="form-input" autofocus=""> 

Я использую код.

import java.util.concurrent.TimeUnit; 

импорт org.openqa.selenium. *; import org.openqa.selenium.htmlunit.HtmlUnitDriver;

общественного класса Столы {

public static void main(String[] args) { 
    // Create a new instance of the html unit driver 
    // Notice that the remainder of the code relies on the interface, 
    // not the implementation. 
    WebDriver driver = new HtmlUnitDriver(); 
    driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 

    // And now use this to visit Google 
    driver.get("https://focus.nassau.k12.fl.us/focus/"); 


    // Find the text input element by its name 
    WebElement element = driver.findElement(By.xpath("//input[@id='username-input']")); 
    element.sendKeys("mcdonaldje"); 



    System.out.println(driver.getCurrentUrl()); 

    // Now submit the form. WebDriver will find the form for us from the element 


    driver.quit(); 
} 

Я получаю эту ошибку

Exception in thread "main" org.openqa.selenium.NoSuchElementException: 
Unable to locate a node using //input[@id='username-input'] 
For documentation on this error, please visit:  
http://seleniumhq.org/exceptions/no_such_element.html 
Build info: version: '2.48.2', revision: '41bccdd', time: '2015-10-09 19:59:12' 
+1

является элементом в '