【发布时间】:2015-06-25 19:47:38
【问题描述】:
我正在尝试自动下载由Teamwork 创建的备份文件。它的工作方式是您登录,然后转到加载动态生成的 iframe 的页面,其中包含 src="https://tw-backup.teamwork.com/ext.cfm?backupaction=downloadLatestMySQLBackup"。
我已经尝试从 iframe 中获取实际链接,但我还没有让它工作。但是,如果我在浏览器中输入截断的链接,我使用的链接似乎可以工作。所以我只是想直接打开它。
不幸的是,它似乎挂了。
编辑
phantomjs --version = 1.9.8;
收到此错误:
[debug] [phantom] url changed to "https://tw-backup.teamwork.com/ext.cfm?backupa
ction=downloadLatestMySQLBackup"
[debug] [phantom] Successfully injected Casper client-side utilities
[info] [phantom] Done 8 steps in 3427ms
finished
Unsafe JavaScript attempt to access frame with URL about:blank from frame with U
RL file:///c:/Users/Brad/AppData/Roaming/npm/node_modules/casperjs/bin/bootstrap
.js. Domains, protocols and ports must match.
那么问题是我尝试访问的子域与我从哪里开始访问不同的子域吗?
如果您对此问题感兴趣,可以免费试用 Teamwork。顺便说一句,我们很好地利用它进行项目管理。
var casper = require('casper').create();
casper.start('https://myco.teamwork.com/', function () {
console.log("start");
this.waitForSelector("input[name='userLogin']",
function success() {
this.sendKeys("input[name='userLogin']", "me@myco.org");
},
function fail() {
test.assertExists("input[name='userLogin']");
});
this.waitForSelector("input[name='password']",
function success() {
this.sendKeys("input[name='password']", "somePassword");
console.log("login successful");
},
function fail() {
test.assertExists("input[name='password']");
console.log("login failed");
});
this.thenOpen('https://tw-backup.teamwork.com/ext.cfm?backupaction=downloadLatestMySQLBackup');
});
【问题讨论】:
-
你有什么 PhantomJS 版本?请注册
resource.error、page.error、remote.message和casper.page.onResourceTimeout活动 (Example)。也许有错误。尝试使用--ssl-protocol=any --ignore-ssl-errors=true运行 CasperJS。 -
@ArtjomB。请查看编辑..
-
那个“错误”(不安全的 JavaScript 尝试...)表明您使用的是 PhantomJS 1.9.8 而不是 1.9.2。 It's actually not an error, but only some string that is printed when CasperJS is exiting。我在您的问题中没有看到错误。如何验证第二个页面加载成功还是失败?
-
对,它是 1.9.8(错字)。日志显示,“[debug] [phantom] url 更改为 tw-backup.teamwork.com/ext.cfm?backupa ction=downloadLatestMySQLBackup”。这不是意味着页面加载成功了吗?
-
是的,确实如此,这就是为什么我要问加载后会执行哪些步骤以及如何验证它是否不起作用。
标签: javascript selenium selenium-webdriver phantomjs casperjs