CasperJS:如何填写asp表单
CasperJS: How to fill a asp form
我正在尝试通过casperjs自动化asp编写网站的几个步骤。我想实现以下目标。
- 导航到登录页面
- 填写用户名和密码字段
- 单击登录按钮
- 捕获成功页面的屏幕截图
但到目前为止,我只能完成该过程的第一步。源视图页面对我来说看起来很少。大多数节点都以<ui:>
标签开头,我对此一无所知。
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="theme/xslt/all.xsl?build=2.0.012&theme=theme_immi" ?>
<!DOCTYPE html [ <!ENTITY nbsp " "> ]>
<ui:root title="ImmiAccount - Login" xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml" xmlns:ui="http://www.immi.gov.au/Namespace/UI/V1.0">
我首先尝试fillSelectors()
提交表单的方法。
casper.start('https://online.immi.gov.au/lusc/login',function() {
this.echo(this.getTitle());
this.fillSelectors('#app_L2',{
'input[id="app_L2b0a0a0a3a1a"]': 'john',
'input[id="app_L2b0a0a0a3b1a"]': 'john123'
});
this.wait('2000',function(){
this.capture('formfill.png');
});
});
casper.then(function() {
// Click on 1st result link
this.click('#app_L2b0a0a0a4a');
this.wait('5000',function(){
this.capture('success.png');
})
});
出现以下错误
CasperError: Errors encountered while filling form: no field matching css selector "input[id="app_L2b0a0a0a3a1a"]" in form;
no field matching css selector "input[id="app_L2b0a0a0a3b1a"]" in form
然后尝试了fillXPath()
casper.start('https://online.immi.gov.au/lusc/login',function() {
this.echo(this.getTitle());
this.fillXPath('#app_L2',{
'//*[@id="app_L2b0a0a0a3a1a"]': 'john',
'//*[@id="app_L2b0a0a0a3b1a"]': 'john123'
});
this.wait('2000',function(){
this.capture('formfill.png');
});
});
casper.then(function() {
// Click on 1st result link
this.click(x('//*[@id="app_L2b0a0a0a4a"]'),
this.wait('5000',function(){
this.capture('success.png');
}));
});
以下错误发生
CasperError: Errors encountered while filling form: Unable to find field element in form: FieldNotFound: Invalid field type; only HTMLElement and NodeList are supported; Unable to find field element in form: FieldNotFound: Invalid field type; only HTMLElement and NodeList are supported
最后,我尝试sendkeys()
方法来填写字段并click()
点击登录按钮。再次,没有找到成功。这里的代码这样做
this.sendKeys('#app_L2b0a0a0a3a1a', 'john');
this.sendKeys('#app_L2b0a0a0a3b1a', 'john123');
this.click(x('//*[@id="app_L2b0a0a0a4a"]'),
this.wait('5000',function(){
this.capture('ctrlqpass.png');
})
);
上面的代码既不会触发错误,也不会触发成功页面。在所有情况下,casper 都会捕获初始页面的屏幕截图。任何帮助非常感谢。谢谢
该页面是一个带有附加样式表 (XSL) 的 XML 文档,用于将页面转换为 HTML 或 XHTML。这是由大多数浏览器自动完成的。
似乎 PhantomJS 是默认编译的,禁用了 XSLT 处理。因此,样式表不会被处理,PhantomJS将其视为任意数据。
你可以使用所需的选项集编译PhantomJS,也可以使用SlimerJS作为CasperJS的引擎。默认情况下,使用的壁虎引擎确实支持 XSLT 转换。
另一种途径可能是使用 JavaScript 中包含的 XSLTProcessor 自己转换内容,但这在 PhantomJS 中也不可用。
相关文章:
- 如何在只能有一个asp.net表单的主页上从asp.net页面中的javascript中获取值
- Jquery Modal表单登录与AJAX-ASP经典上的IE 9
- 有什么“;错误的”;将javascript放在asp.net表单上,而不是放在单独的文件中
- 输入文本框为空时的阻止按钮asp.网络表单
- JavaScript表单提交没有't fire asp服务器端点击功能的提交按钮
- 表单未使用 MVC 提交任何值 Asp.Net
- ASP MVC复选框表单提交问题
- 在ASP.NET中单击“提交”按钮时,使表单不刷新
- 如何使用javascript在asp.net网页表单上动态添加文本框
- asp.net mvc中的javascript验证不适用于登录表单
- asp.net web表单客户端验证始终回发
- 在带有 bootbox 的自定义对话框中添加选项以选择表单控件.js在 ASP.NET MVC 中
- 使用Bookmarklet在Firefox中为asp表单加载启动onclick事件
- 使用asp.net表单引导
- 使用Html.BeginFrom在ASP.Net MVC中提交一个带有锚(<a>)标记且具有一定值的表单
- 是否可以在没有视图状态和回发的情况下使用asp.net web表单
- ASP表单在服务器上运行,不允许内部HTML按钮onlick setInterval工作
- CasperJS:如何填写asp表单
- 从 Java 应用程序提交 ASP 表单
- 如何让经典的ASP表单识别输入中的变化