Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all articles
Browse latest Browse all 97773

org.openqa.selenium.NoSuchElementException no such element: Unable to locate element

$
0
0

I am try to test the login function using selenium but I get this exception :

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@name='Guichet']"}

this my code :

public class LoginTest {

    public static WebDriver driver; 

    @BeforeClass
    public void testSetup() {
        System.setProperty("webdriver.chrome.driver", "C:\\driver\\chromedriver.exe");
        driver=new ChromeDriver();
        driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
        //driver.manage().window().maximize();

    }

    @BeforeMethod
    public void openBrowser() {
        driver.get("http:url");
        System.out.println("We are currently on the following URL" +driver.getCurrentUrl());
    }

    @Test(description="This method validates the login functionality")
    public void loginFunction() {
        //WebDriverWait gui = new WebDriverWait(driver,100);

        //Locating the email field element via Name tag and storing it in the webelement
        WebElement guichet = driver.findElement(By.xpath("//input[@name='Guichet']"));
        WebElement matricule = driver.findElement(By.name("Matricule"));
        WebElement password = driver.findElement(By.name("Mot_de_passe"));
        WebElement save = driver.findElement(By.name("Valider"));
        //Entering text into the email field
        guichet.sendKeys("0000");

        matricule.sendKeys("login");
        password.sendKeys("password");
        save.click();

    }
    @AfterMethod
    public void postLogin(){
        System.out.println(driver.getCurrentUrl());
        Assert.assertEquals(driver.getCurrentUrl(), "http:url.html");
    }

    @AfterClass
    public void afterClass(){
        //driver.quit();
    }
}

NB : I tried to use the and xpath but still does not work also I try to using some solution in this Post but no result

This the Html page Using the frame for menu and other form login pages

SCT

:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<META name="GENERATOR" content="">
<META http-equiv="Content-Style-Type" content="text/css">
<TITLE> 
</TITLE>
<LINK href="Master.css" rel="stylesheet" type="text/css">
</HEAD>
<FRAMESET rows="14%,78%" frameborder="NO" border="0">
  <FRAME src="menu.html" scrolling="NO" name="entete">
  <FRAME src="SCT.html">
  <NOFRAMES>
  <BODY BGCOLOR="#FFFFFF">
  <P>L'affichage de cette page requiert un navigateur prenant en charge les
  cadres.</P>
  </BODY>
  </NOFRAMES>
</FRAMESET>
</HTML>

Viewing all articles
Browse latest Browse all 97773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>