Skip to content

Instantly share code, notes, and snippets.

@ypresto
Created December 16, 2012 15:07
Show Gist options
  • Save ypresto/4308281 to your computer and use it in GitHub Desktop.
Save ypresto/4308281 to your computer and use it in GitHub Desktop.
casperjs iframe test example
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<iframe name="ad_iframe" src="./casper_test.html" />
</body>
</html>
/*global require:false */
var casper = require('casper').create();
casper.start('./iframe_test.html');
casper.withFrame('ad_iframe', function () {
this.test.assertUrlMatch(/casper_test\.html/, 'i am on inside of iframe');
this.test.assertVisible('#hoge', 'hoge is clickable');
this.clickLabel('clickable hoge');
});
casper.withFrame('ad_iframe', function () {
this.test.assertUrlMatch(/#!\/hoge/, 'hash changed to hoge');
this.test.assertNotVisible('#fuga', 'fuga is not clickable');
this.clickLabel('unclickable fuga');
});
casper.withFrame('ad_iframe', function () {
this.test.assertUrlMatch(/#!\/hoge/, 'hash not changed to fuga');
this.echo("I'm sorry, it's clickable...");
});
casper.run();
@eclair04
Copy link

eclair04 commented Jun 22, 2017

Is there any way we can fill up a form inside casper.withFrame() for example this.sendKeys() or this.fill() or this.fillSelectors()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment