使用 getControl 控制除 name 变量以外的对象
我正在使用我上一个问题中推荐的 Zope testbrowser。我面临的问题是我可以使用 getControl 函数来控制不同的对象,例如:密码、用户名等。
我试图提交页面以进入下一页,但提交按钮没有“名称”变量,只是一个“id”变量。 “提交”的写法如下:
<input type="submit" id="lgn_button" class="button" tabindex="3" accesskey="s" />
其他对象的写法为:
<input type="password" class="button" name="password" id="password" size="24" maxlength="20" accesskey="p" tabindex="2" value=""/></td>
我无权更改此设置。我用来控制“密码”对象的 python zope 代码是:
browser.getControl(name='password')
提交按钮没有“名称”,所以我写了:
browser.getControl(id='lgn_button')
这会打印出“id”无效的错误:
TypeError: getControl() got an unexpected keyword argument 'id'
有没有办法获得对“提交”中其他值之一的控制。
感谢您的任何帮助。
I am using the Zope testbrowser which has been recommended in my last question. The problem that I am facing is that I can use the getControl function to control different objects like: password, username etc.
I am trying to submit the page to get to the next page but the submit button has no 'name' variable, just an 'id' variable. 'Submit' is written as follows:
<input type="submit" id="lgn_button" class="button" tabindex="3" accesskey="s" />
and the other objects are written as:
<input type="password" class="button" name="password" id="password" size="24" maxlength="20" accesskey="p" tabindex="2" value=""/></td>
I have no access to change this. The python zope code I am using to gain control of the 'password' object is:
browser.getControl(name='password')
The submit button doesn't have 'name' so I have written:
browser.getControl(id='lgn_button')
This prints out the error that 'id' is invalid:
TypeError: getControl() got an unexpected keyword argument 'id'
Is there any way to gain control of one of the other values in 'submit'.
Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我假设,出于某种原因,您无法向标签添加“名称”属性,但如果您只能添加一个“名称”,则可以显式设置“值=提交”(而不是依赖默认的,即 Submit),然后使用 browser.getControl('Submit')
如果失败,您可以按照
您甚至可能想扩展 Browser.getControl() 的方式进行一些操作并贡献它回到 zope.testbrowser。 ;)
I assume that, for one reason or another, you can't add a 'name' attribute to your tag, but if it's only a 'name' that you can't add, you can explicitly set a 'value=Submit' (instead of relying on the default one, which is Submit) and then use browser.getControl('Submit')
Failing that, you can do something along the lines of
You might even want to extend Browser.getControl() with that and contribute it back to zope.testbrowser. ;)