我的页面上有html元素,这是在表单登录后的安全页面上
<h4 class="something" id="somethingelse1" style="display: none;">Some Name</h4>
<h4 class="something" id="somethingelse2" style="display: none;">Some other name</h4>
Run Code Online (Sandbox Code Playgroud)
我希望能够模拟此元素的单击,然后将加载新页面.一旦加载了新页面,我想在其中拍摄div元素的快照.我有一部分拍摄快照,但我无法找到基于其文本点击元素的方法.例如,模拟上面的H4元素的点击,其中文本是'其他名称'
这就是我到目前为止......
var casper = require('casper').create({
pageSettings: {
loadImages: true,
loadPlugins: true
}
});
casper.start('http://localhost/', function() {
console.log("page loaded");
this.fill('form#login-form', {
username: 'lbguy',
password: 'lbguypass'
}, true);
});
casper.thenOpen('http://localhost/MysecureSite/page1', function() {
this.echo(this.getTitle());
var query_xpath = '//*[@innerHtml="Some other name"]';
require('utils').dump(this.getElementAttribute(query_xpath , 'id'));
//casper.start('http://localhost/MysecureSite/page2', function() {
// this.captureSelector('pic.png', '#someelement');
//});
});
Run Code Online (Sandbox Code Playgroud)
在页面标题之后,控制台只输出"Null".我不确定这是否也是正确的方法.目标是基于我将以编程方式发送的选定文本来模拟H4元素的单击,然后在该单击操作加载名为someelement的div的第2页之后在第2页上创建快照.
UPDATE
页面加载后,h4元素通过jquery动态添加到页面中.
谢谢
我有一个用VB 6.0开发的应用程序.我无法访问其代码.此应用程序还通过其dll中提供的某些API公开其功能.有没有办法让我检查该应用程序的API的消费者在部署API的任何地方调用API的方法.我希望C#程序只是坐在那个目标环境中,拦截对该API的调用,并通过服务将其报告给我的服务.我不会修改API或调用API的代码.这在C#中是可行的还是我需要使用C++?
更新
让我们说为了简单起见,它是一个简单的VB应用程序,在VB 6中开发,名为SimpleAPP,它有一个按钮,可以在网格中显示记录.它通过使用公共方法GetRecords(字符串ID)调用组件CMPA.dll来执行此操作,该方法返回记录数组.我有另外几个名为CustomerApp.exe和AnotherCustomerApp.exe的应用程序,它们也有对CMPA.dll的引用,并且它们都调用相同的方法来获取记录.现在,我想开发一个名为Interceptor.exe的程序,该程序实际上将位于部署CustomerApp和AnotherCustomerApp的环境中,并将在内部记录这两个应用程序中的哪一个称为CMPA dll的公共方法GetRecords,并记录它发送的参数和检索到了什么结果.