Re: Can't find input field

685 views
Skip to first unread message

Markus Bernhardt

unread,
Jun 12, 2013, 11:18:48 AM6/12/13
to liljegre...@gmail.com, robotframe...@googlegroups.com
Well, id should be really unique on a html page. Or??? 
Look: http://www.w3schools.com/tags/att_global_id.asp

Although you don't have to change your app. You could use for example a xpath locator:

    input text    xpath=//input[@id='username']    joe.bloggs

Cheers,
Markus

Am 12.06.2013 um 17:04 schrieb Fredrik Liljegren <liljegre...@gmail.com>:

Hi,

I'm a new user of Robot Framework and have just run into a problem. I'm creating a test where I login to a web page and perform some actions. But I can't get the actual login procedure to work.

Now, I've managed to do it on another site, so my basic idea is right. I suspect that the structure of the page under test is the issue:

code snippet from page:

<p id="username">
 <label for="username"> Username</label>
<br>
<input id="username" class="inputbox" type="text" size="18" alt="Username" name="username">
</p>
<p id="password">
<label for="passwd"> Password</label>
<br>
<input id="passwd" class="inputbox" type="password" alt="Password" size="18" name="password">
</p>

My test looks like this:

*** Settings ***
Test Teardown     close browser
Library           Selenium2Library

*** Test Cases ***
Test Login
    open browser    http://web.url.com    firefox
    Maximize Browser Window
    Title should be    Pageheader
    input text    username    joe.bloggs
    input password    passwd    secret


The error I get when running is:

16:47:33.813 
INFO  Typing text 'joe.bloggs' into text field 'username'
16:47:34.035  FAIL 
WebDriverException: Message: u'Element must be user-editable in order to clear it.' ; Stacktrace: at bot.Error (file:///c:/users/fredri~1.fre/appdata/local/temp/tmpkan0o7/webdriver-py-profilecopy/extensions/fxdr...@googlecode.com/components/command_processor.js:3290) at bot.action.clear (file:///c:/users/fredri~1.fre/appdata/local/temp/tmpkan0o7/webdriver-py-profilecopy/extensions/fxdr...@googlecode.com/components/command_processor.js:9505) at WebElement.clearElement (file:///c:/users/fredri~1.fre/appdata/local/temp/tmpkan0o7/webdriver-py-profilecopy/extensions/fxdr...@googlecode.com/components/command_processor.js:9939) at DelayedCommand.prototype.executeInternal_/h (file:///c:/users/fredri~1.fre/appdata/local/temp/tmpkan0o7/webdriver-py-profilecopy/extensions/fxdr...@googlecode.com/components/command_processor.js:10456) at DelayedCommand.prototype.executeInternal_ (file:///c:/users/fredri~1.fre/appdata/local/temp/tmpkan0o7/webdriver-py-profilecopy/extensions/fxdr...@googlecode.com/components/command_processor.js:10461) at DelayedCommand.prototype.execute/< (file:///c:/users/fredri~1.fre/appdata/local/temp/tmpkan0o7/webdriver-py-profilecopy/extensions/fxdr...@googlecode.com/components/command_processor.js:10401)

Entering the password works just fine, but not the username. Could it be the fact that the input id and name is identical for username (they are not for password)? If so, is there a workaround (that doesn't include changing the code on the web page)?

Thanks in advance.

--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at http://groups.google.com/group/robotframework-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Fredrik Liljegren

unread,
Jun 12, 2013, 12:02:08 PM6/12/13
to robotframe...@googlegroups.com, liljegre...@gmail.com
Thank you very much, the xpath method did the trick (I really have to get familiar with xpaths).

I know, the id should be unique. However, the web page we're doing the tests on is not our own, so we don't have any real input in the matter ;)

  // Fredrik
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-users+unsub...@googlegroups.com.

Jason Zhao

unread,
Jun 23, 2013, 9:23:53 PM6/23/13
to robotframe...@googlegroups.com, liljegre...@gmail.com
the error was webdriver,so you might want to try this :
1.use other browser instead to see if it would happen again
2.if so, you might have to check firefox_profile.py ,to switch self.profile_dir = newprof into self.profile_dir = str(newprof)

juan carlos marin castro

unread,
Jun 24, 2013, 12:15:08 AM6/24/13
to robotframe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages