Python Forum
Unable to locate element no such element
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Unable to locate element no such element
#1
<td> 
    <div class="input-icon">
        <i class="fa fa-user"></i>
        <script type="text/javascript">
            if (getQueryStringParameter("Back") == 1) {                        
                document.write("<input class='form-control placeholder-no-fix' type='text' autocomplete='off' placeholder='User ID' name='tempusername' id='username' autocomplete='off' size='14' maxlength='12' value='' /> <input type='hidden' name='username'>");
            } else {
                document.write("<input class='form-control placeholder-no-fix' type='text' autocomplete='off' placeholder='User ID' name='tempusername'  autocomplete='off' size='14' maxlength='12' value='' /><input type='hidden' name='username'>");
            }
        </script>
        <input class="form-control placeholder-no-fix" type="text" autocomplete="off" placeholder="User ID" name="tempusername" size="14" maxlength="12" value=""><input type="hidden" name="username">
    </div>
 </td>
Capture

time.sleep(5)
driver.find_element_by_name('//*[@id="LoginId"]/table/tbody/tr[3]/td/div/input[1]').send_keys("username1")
I did tried wait 20 seconds which is more than enough to let the page finish loaded.
But the result still same. I also tried get the element by name but result the same tho.
Please advise.
Reply
#2
Can you post a little bit more of your html ? or at least so that we can verify your xpath is correct? I can't see element with id 'LoginId' for example.

Yeah and also your traceback says you are using xpath method but in your code sample you are trying to find element by name?
driver.find_element_by_name('//*[@id="LoginId"]/table/tbody/tr[3]/td/div/input[1]').send_keys("username1") 
should be
driver.find_element_by_xpath('//*[@id="LoginId"]/table/tbody/tr[3]/td/div/input[1]').send_keys("username1")
Reply
#3
(Feb-14-2019, 08:13 PM)mlieqo Wrote: Can you post a little bit more of your html ? or at least so that we can verify your xpath is correct? I can't see element with id 'LoginId' for example.

Yeah and also your traceback says you are using xpath method but in your code sample you are trying to find element by name?
driver.find_element_by_name('//*[@id="LoginId"]/table/tbody/tr[3]/td/div/input[1]').send_keys("username1") 
should be
driver.find_element_by_xpath('//*[@id="LoginId"]/table/tbody/tr[3]/td/div/input[1]').send_keys("username1")

<form class="login-form" name="LoginForm" id="LoginId" action="/eaijct/cnpy" method="post" onsubmit=" return doSubmit_CNPY();">
        <table width="100%">
    		<tbody><tr>
    			<td width="45%" valign="bottom">
    				<h3 class="form-title" id="login-title">Login to PBe</h3>
    			</td>
        	</tr>
        	<tr>  
    			<td align="right" valign="bottom" style="padding-right:20px">
    			<p class="form-title">                                                           
    				 
    				Friday, 15 February 2019 06:58:05
    				</p>
    			</td>
    		</tr>
    		

        <!--div class="alert alert-danger display-hide">
				<button class="close" data-close="alert"></button>
				<span>Enter any user id and password.</span>
        <div class="form-group">
            <!--ie8, ie9 does not support html5 placeholder, so we just show field title for that...-->
           <tr><td> 
            <div class="input-icon">
                <i class="fa fa-user"></i>
                <script type="text/javascript">
                    if (getQueryStringParameter("Back") == 1) {                        
                        
                        document.write("<input class='form-control placeholder-no-fix' type='text' autocomplete='off' placeholder='User ID' name='tempusername' id='username' autocomplete='off' size='14' maxlength='12' value='' /> <input type='hidden' name='username'>");
                    } else {

                        document.write("<input class='form-control placeholder-no-fix' type='text' autocomplete='off' placeholder='User ID' name='tempusername'  autocomplete='off' size='14' maxlength='12' value='' /><input type='hidden' name='username'>");
                    }
                </script><input class="form-control placeholder-no-fix" type="text" autocomplete="off" placeholder="User ID" name="tempusername" size="14" maxlength="12" value=""><input type="hidden" name="username">
            </div>
            </td></tr>
            </tbody></table>
        </form>
Sorry. Was copy wrong, it should get element by xpath.
Reply
#4
are you sure this is right?
tr[3]
Can you post the link to the site so we can check to see if there is anything else?
Reply
#5
(Feb-15-2019, 12:14 AM)metulburr Wrote: are you sure this is right?
tr[3]
Can you post the link to the site so we can check to see if there is anything else?

https://www2.pbebank.com/myIBK/apppbb/ba...emain.html
Reply
#6
That link does not work for me. But if i remove the 2 from www i go to their home page. And if i try to login i get this. IS that the correct location?
   

If so then i get for xpath for that login field is...
/html/body/div[1]/form/table/tbody/tr[3]/td/div/input[1]
Reply
#7
(Feb-17-2019, 05:58 PM)metulburr Wrote: That link does not work for me. But if i remove the 2 from www i go to their home page. And if i try to login i get this. IS that the correct location?


If so then i get for xpath for that login field is...
/html/body/div[1]/form/table/tbody/tr[3]/td/div/input[1]

Yeah. That the login page of the website.
But I tried your xapth still the same error tho.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  sorting a list of lists by an element leapcfm 3 158 Sep-10-2021, 03:33 PM
Last Post: leapcfm
  myList.insert(index, element) question ChrisF 1 184 Aug-27-2021, 03:49 PM
Last Post: bowlofred
  How do I locate setup.py in my computer, or install the file? JaneTan 1 192 Aug-26-2021, 08:37 AM
Last Post: snippsat
  Scraping a Flexible Element - works at first, and then crashes JonnyB 0 149 Aug-14-2021, 07:25 PM
Last Post: JonnyB
  acess particular element in dataframe using .loc operator. shantanu97 0 220 Jun-30-2021, 03:59 AM
Last Post: shantanu97
  Convert each element of a list to a string for processing tester_V 6 753 Jun-16-2021, 02:11 AM
Last Post: tester_V
  Compare each element of an array in a logic statement without using a for loop leocsmith 3 938 Apr-01-2021, 07:57 PM
Last Post: deanhystad
  splitting lines, need to add element of same kind tester_V 6 863 Feb-20-2021, 11:51 PM
Last Post: tester_V
  If an element of a 'Split' is empty tester_V 6 771 Feb-19-2021, 05:04 AM
Last Post: deanhystad
Photo i want to locate an image according to the mouse position rachidel07 1 578 Feb-08-2021, 03:29 PM
Last Post: michael1789

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020