Typing text into input box often leaves box blank

474 views
Skip to first unread message

Greg

unread,
Jul 31, 2012, 9:00:01 PM7/31/12
to seleniu...@googlegroups.com
I know my title might be confusing so I'll go into more detail:

I have a very straight-forward scenario where I need to type a temporary password into an input box. Sometimes Selenium will input the text and it will show on the screen, and then the test will click a button, yielding a successful test. However, often the test will enter text, yet the screen will stay blank, yet Selenium registers that its action was completed successfully. Then Selenium will click a button, obviously leading to a test failure.

@test
def sometest():
..
test_page.enter_temp_password(password)
...

def enter_temp_password(self, tempPass):
        try:
            self.driver.find_element_by_tag_name("input").send_keys(tempPass)
        except StaleElementReferenceException:
            self.driver.find_element_by_tag_name("input").send_keys(tempPass)

Html:
<fieldset class="verify-fieldset">     
<label for="tempPassword">Verification code</label>     
<div class="error off"></div>     
<input type="text" class="input-hasPlaceholder" id="tempPassword" name="tempPassword">     
<div class="instructions">       
<p class="resendSMS-blurb">Didn't get the text? <a "href="#" class="resendSMS-link">Resend it</a></p>       
<p class="sentSMS displayNone">Text sent</p>       
<span class="progress off"></span>     
</div>   
</fieldset>

I've tried alot of different stuff from implicit waits to funky loops as well, nothing worked 100% although implicit waits worked the best, but thats not saying much. So I'm thinking the machine I'm running my webpage on might be slightly funky. I've looked at the memory and it seems like 457/967mb are taken on the machine. Which wouldn't really raise my eyebrows, except I'm basically stumped, so imo anything is possible. Has anyone had any experience with this kind of problem before?

Thanks,
Greg

Greg

unread,
Jul 31, 2012, 9:55:18 PM7/31/12
to seleniu...@googlegroups.com
I actually seem to have gotten it working using:

def enter_temp_password(self, tempPass):  
       
try:      
           
self.regdriver.find_element_by_tag_name(element_locators['tempField']).send_keys(tempPass)  
       
except Exception:
           
self.regdriver.find_element_by_tag_name(element_locators['tempField']).send_keys(tempPass)
       
self.check_for_pass(tempPass)

   
def check_for_pass(self, tempPass):

        field
= self.regdriver.find_element_by_tag_name(element_locators['tempField']).get_attribute("value")

       
while field != tempPass:  
           
self.regdriver.find_element_by_tag_name(element_locators['tempField']).send_keys(tempPass)
            field
= self.regdriver.find_element_by_tag_name(element_locators['tempField']).get_attribute("value")


This is pretty hacky though, I was wondering if anyone knows the general theory as to why I might not have been finding my stuff in the first place

Greg

DongXiang

unread,
Aug 1, 2012, 12:50:52 AM8/1/12
to seleniu...@googlegroups.com
Try to click the element before sendKeys. I got the same problem but solved after add a click.
 

Date: Tue, 31 Jul 2012 18:55:18 -0700
From: gre...@gmail.com
To: seleniu...@googlegroups.com
Subject: [selenium-users] Re: Typing text into input box often leaves box blank
--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/ait7uAue1rYJ.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Greg

unread,
Aug 1, 2012, 1:07:05 PM8/1/12
to seleniu...@googlegroups.com
Tried the click command, and it didnt do anything for me.

Stefan Teixeira

unread,
Aug 1, 2012, 8:48:01 PM8/1/12
to seleniu...@googlegroups.com
I got a problem like this once, because the fields I wanted to fill had too much ajax validations. The solution that worked for me was to click the element, put the Thread to sleep a few seconds, and then send keys to fill it.

2012/8/1 Greg <gre...@gmail.com>
Tried the click command, and it didnt do anything for me.

--
You received this message because you are subscribed to the Google Groups "Selenium Users" group.
To post to this group, send email to seleniu...@googlegroups.com.
To unsubscribe from this group, send email to selenium-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/selenium-users/-/96lJ5piuIrYJ.
Reply all
Reply to author
Forward
0 new messages