-1

I am trying to locate the login into a webpage but am not able to do the same as the element is not visible - getting Nosuchelement exception.

i tried using the below code but each time i get the exception. WebDriverWait wait = new WebDriverWait(driver, 30); wait.until(ExpectedConditions.visibilityOfAllElementsLocatedBy(By.xpath("html/body/form/table/tbody/tr[3]/td[2]/input"))); driver.findElement(By.xpath("html/body/form/table/tbody/tr[3]/td[2]/input")).sendKeys("admin");

Can anyone please help me in this.

Thanks HTML Code for the page is :-

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <title>Retail-J</title>
    </head>


    <frameset name ="mainFrameset" id ="mainFrameset" rows="55,*" frameborder="1" framespacing="2" border="2" bordercolor="#000000">
        <frame name="titleFrame" src="title.jsp" marginheight="0" marginwidth="0" noresize="noresize" scrolling="no">
        <frameset name="innerFrameset" id="innerFrameset" cols="20.0%,*" frameborder="0" border="0" framespacing="0" >
            <frame name="contentFrame"  src="dynamicContents.jsp" marginheight="0" marginwidth="0" noresize="noresize" target="mainFrame" scrolling="auto">
            <frame name="mainFrame" src="Welcome.jsp" marginheight="0" marginwidth="0" scrolling="auto">
        </frameset>
        <noframes> 
            <body bgcolor="#FFFFFF" text="#000000" topmargin="0" leftmargin="0">
            Sorry your browser does not support framesets. 
             </body>
        </noframes> 
    </frameset>
</html>
abhishek pandey
  • 83
  • 1
  • 3
  • 13

3 Answers3

0

The question is a little vague as you don't provide any example of the related DOM; however you can start by verifying that the intended element is actually visible for the browser. Some times login elements are hidden and only appear upon a user action (such as mouse click or mouse over). Selenium has a couple of functions that will allow you to render the element visible (see here). If nothing else seems to work, you can use the Javascript executor to find the element and return it for use, although it is not considered a good practice.

Community
  • 1
  • 1
LCO TEC BAJA
  • 678
  • 5
  • 5
0

NoSuchElement exception means that your locator is not correct. Try below things:

  1. Try To Find element using ID , NAME or XPATH. Make sure locator is unique?
  2. Check if element is inside a iframe/frame?
  3. Wait for element visibility.

Let me know if it works for you.

Shailendra
  • 431
  • 5
  • 14
  • 1
    So your element is inside frame. Please first switch inside frame (frame name="contentFrame") , and then interact with input field. – Shailendra Apr 27 '17 at 06:56
0

You've not specified what language you're using for your project so I'm just going to give an answer in C#.

At a guess I would assume it's a mixture of the web driver executing too fast and also using the wrong locators, possibly a login page that uses the same ID multiple times too which complicate things.

Add the following wait to your solution and see if it helps:

    Task.Delay(2000).Wait();