-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfootaction.js
132 lines (99 loc) · 3.09 KB
/
footaction.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// casperjs footaction.js --engine=slimerjs --ssl-protocol=TLSv1
//var casper = require('casper').create();
var casper = require("casper").create({
onRunComplete: function() {
// Don't exit on complete.
}
});
casper.options.viewportSize = {
width: 1200,
height: 950
};
casper.options.waitTimeout = 9999999999;
//YEEZY
var url = 'http://www.footaction.com/product/model:254106/sku:AQ4832/adidas-originals-yeezy-boost-350/?SID=7040&cm_mmc=Social-_-twitter-_-yeezy-_-blackwhite';
//test url
//var url = 'http://www.footaction.com/product/model:242054/sku:25231176/nike-zoom-cj-trainer-3-mens/calvin-johnson/detroit-lions/#sku=25231176&size=10.0';
var pwd = 'password1';
casper.start(url, function() {
this.echo(this.getTitle());
});
//WAIT for time to be ZERO
// casper.waitForText("0 hours 0 min 0 sec", function() {
// this.echo('Found the time!');
// });
// casper.wait(1500, function() {
// this.echo("I've waited for 1.5 seconds.");
// });
casper.then(function() {
casper.evaluate(function() {
console.log('inside size click');
var aTags = document.getElementsByClassName("available");
var searchText = "10.0";
var found;
for (var i = 0; i < aTags.length; i++) {
if (aTags[i].textContent == searchText) {
found = aTags[i];
break;
}
}
found.click();
});
});
casper.wait(750, function() {
this.echo("I've waited for .75 seconds.");
});
casper.thenClick('#addToCartLink', function() {
this.echo('add to cart clicked');
});
casper.wait(750, function() {
this.echo("I've waited for .75 seconds.");
});
casper.thenClick('[data-btnname="minicart_viewFullCart"]', function() {
this.echo('view full cart');
});
// casper.wait(1000, function() {
// this.echo("I've waited for 1 seconds after checkout review clicked.");
// });
casper.waitUntilVisible('[data-btnname="cart_checkout"]', function() {
this.echo('cart checkout btn is visible.');
});
casper.thenClick('[data-btnname="cart_checkout"]', function() {
this.echo('cart checkout ... now onto secure page');
});
//Below this starts checkout page logic
//----------
casper.wait(1000, function() {
this.echo("waiting 1 seconds to fill out login form.");
});
// casper.thenClick('#loginPaneEmailAddress', function(){
// this.echo('checkout page is visible');
// });
casper.then(function() {
this.fillSelectors('#loginPane_edit', {
'input[name="loginPaneEmailAddress"]': '[email protected]',
'input[name="loginPanePassword"]': pwd
}, false);
});
//clicks hidden button
//otherwise, click real btn by doing .buttonSection .btn-primary.leftArrow
casper.thenClick('#loginPaneLogin', function() {
this.echo('login clicked');
});
// casper.wait(1500, function() {
// this.echo("waiting 1.5 seconds to fill out CVV.");
// });
casper.waitUntilVisible("#orderReviewPane_edit", function() {
this.echo('CVV panel is visible.');
});
casper.then(function() {
this.fill('#orderReviewPane_edit', {
'payMethodPaneStoredCCCVV': '123'
}, false);
});
casper.then(function() {
this.wait(10000000, function() {
this.echo("I've waited for 10000 second.");
});
});
casper.run();