2016-05-13 7 views
0

Windows版でEclipseバージョン:Luna Release(4.4.0)を使用しています。セレン(V 2.53)のコードが正常に動作しています。しかしJunitを使用するとIDで要素を見つけることができません

f.get("https://mail.yahoo.com"); 
f.findElement(By.id("login-username")).sendKeys("jj%jo.com"); 

WebElement element = f.findElement(By.id("login-username")); 
String text = element.getAttribute("value"); 
System.out.println(text); 

、私はプロジェクトであるJunit v4.12とTestNGのを追加>ビルドパスコードは要素を見つけることができません。

@Test 
public void testFindUsername(){ 
    f.findElement(By.id("login-username")).click(); 
    f.findElement(By.id("login-username")).sendKeys("[email protected]"); 
} 

Error: Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate element: {"method":"id","selector":"login-username"} For documentation on this error, please visit:

http://seleniumhq.org/exceptions/no_such_element.html

誰にも親切に私たちが解決策を知っている、この問題を持っていた場合。

はあなた

+0

は、いくつかの待ち時間の後、感謝を – noor

+0

は、それが動作するようになったURLを取得しますありがとうございました。 –

答えて

0
import java.util.Scanner; 

public class CreateGuest { 

    public static void main(String[] args) { 
     String name = getGuestName(); 
     printName(name); 
    } 

    public static String getGuestName() { 
     Scanner in = new Scanner(System.in); 
     System.out.print("Enter name: "); 
     String name = in.next(); 
     in.close(); 
     return name; 
    } 

    public static void printName(String name) { 
     System.out.println("You entered: " + name); 
    } 

} 
関連する問題