2015-03-30 2 views
0

Может кто-нибудь указать мне на пример, чтобы сделать скрипт CasperJS/PhantomJS, который входит в Intacct и отображает кепку экрана.Войдите в Intacct с помощью CasperJS, чтобы очистить

casper = require("casper").create({ 
    waitTimeout: 60000, 
    viewportSize: { 
     width: 1024, 
     height: 768 
    }, 
    verbose: true, 
    logLevel: 'debug', 
    pageSettings: { 
     loadImages: false, 
     loadPlugins: false, 
     userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X)' 
    } 
}); 

casper.start("https://www.intacct.com/ia/acct/login.phtml"); 

casper.then(function() { 
    casper.fill('form[name="iamain"]', { 
     '.company': 'company', 
     '.login': 'username', 
     '.passwd': 'password', 
    }, true); 
}); 

casper.then(function() { 
    casper.capture("screen.png"); 
}); 

casper.run(); 

** ОБНОВЛЕНО код из ПРЕДЛОЖЕНИЮ НИЖЕ

изображение, которое она сохраняет только тот же самый экран Войти.

Это то, что показывает на экране CMD (ОБНОВЛЕНО):

Warning PhantomJS v2.0 not yet released. There will not be any official support for any bugs until stable version is released! 
[info] [phantom] Starting... 
[info] [phantom] Running suite: 4 steps 
[debug] [phantom] opening url: https://www.intacct.com/ia/acct/login.phtml, HTTP GET 
[debug] [phantom] Navigation requested: url=https://www.intacct.com/ia/acct/login.phtml, type=Other, willNavigate=true, isMainFrame=true 
[debug] [phantom] url changed to "https://www.intacct.com/ia/acct/login.phtml" 
[debug] [phantom] Navigation requested: url=https://www.intacct.com/ia/logincontent/product/index.html, type=Other, willNavigate=true, isMainFrame=false 
[debug] [phantom] Navigation requested: url=https://www.intacct.com/ia/logincontent/marketing/index.html, type=Other, willNavigate=true, isMainFrame=false 
[debug] [phantom] Navigation requested: url=https://www.intacct.com/ia/acct/login.phtml?.topper=%2Fia%2Facct%2Flogin.phtml, type=Other, willNavigate=true, isMainFrame=false 
[debug] [phantom] Navigation requested: url=https://googleads.g.doubleclick.net/pagead/viewthroughconversion/1071821189/?random=1427724789483&cv=7&fst=1427724789483&num=1&fmt=1&label=2QNMCIiK0AMQheOK_wM&guid=ON&u_h=1080&u_w=1920&u_ah=1040&u_aw=1920&u_cd=32&u_his=1&u_tz=-240&u_java=false&u_nplug=0&u_nmime=0&frm=1&url=https%3A//www.intacct.com/ia/acct/login.phtml&ref=https%3A//www.intacct.com/ia/acct/login.phtml&vis=1, type=Other, willNavigate=true, isMainFrame=false 
[debug] [phantom] Navigation requested: url=https://www.google.com/ads/user-lists/1071821189/?label=2QNMCIiK0AMQheOK_wM&fmt=1&num=1&cv=7&frm=1&url=https%3A//www.intacct.com/ia/acct/login.phtml&ref=https%3A//www.intacct.com/ia/acct/login.phtml&random=2994291944, type=Other, willNavigate=true, isMainFrame=false 
[debug] [phantom] Successfully injected Casper client-side utilities 
[debug] [phantom] start page is loaded 
[info] [phantom] Step anonymous 3/4 https://www.intacct.com/ia/acct/login.phtml (HTTP 200) 
[info] [remote] attempting to fetch form element from selector: 'form[name="iamain"]' 
[debug] [remote] Set ".company" field value to company 
[debug] [remote] Set ".login" field value to username 
[debug] [remote] Set ".passwd" field value to ************ 
[info] [remote] submitting form to login.phtml?.done=frameset.phtml, HTTP POST 
[info] [phantom] Step anonymous 3/4: done in 1889ms. 
[info] [phantom] Step anonymous 4/4 https://www.intacct.com/ia/acct/login.phtml (HTTP 200) 
[debug] [phantom] Capturing page to C:/Users/mycomputer/Desktop/Phantom Test/screen.png 
[info] [phantom] Capture saved to C:/Users/mycomputer/Desktop/Phantom Test/screen.png 
[info] [phantom] Step anonymous 4/4: done in 2073ms. 
[debug] [phantom] Navigation requested: url=https://www.intacct.com/ia/acct/login.phtml?.done=frameset.phtml, type=FormSubmitted, willNavigate=true, isMainFrame=true 
[debug] [phantom] url changed to "https://www.intacct.com/ia/acct/login.phtml?.done=frameset.phtml" 
[debug] [phantom] Navigation requested: url=https://www.intacct.com/ia/logincontent/product/index.html, type=Other, willNavigate=true, isMainFrame=false 
[debug] [phantom] Navigation requested: url=https://www.intacct.com/ia/logincontent/marketing/index.html, type=Other, willNavigate=true, isMainFrame=false 
[debug] [phantom] Navigation requested: url=https://www.intacct.com/ia/acct/login.phtml?.topper=%2Fia%2Facct%2Flogin.phtml%3F.done%3Dframeset.phtml, type=Other, willNavigate=true, isMainFrame=false 
[debug] [phantom] Navigation requested: url=https://googleads.g.doubleclick.net/pagead/viewthroughconversion/1071821189/?random=1427724790656&cv=7&fst=1427724790656&num=1&fmt=1&label=2QNMCIiK0AMQheOK_wM&guid=ON&u_h=1080&u_w=1920&u_ah=1040&u_aw=1920&u_cd=32&u_his=2&u_tz=-240&u_java=false&u_nplug=0&u_nmime=0&frm=1&url=https%3A//www.intacct.com/ia/acct/login.phtml%3F.done%3Dframeset.phtml&ref=https%3A//www.intacct.com/ia/acct/login.phtml%3F.done%3Dframeset.phtml&vis=1, type=Other, willNavigate=true, isMainFrame=false 
[debug] [phantom] Navigation requested: url=https://www.google.com/ads/user-lists/1071821189/?label=2QNMCIiK0AMQheOK_wM&fmt=1&num=1&cv=7&frm=1&url=https%3A//www.intacct.com/ia/acct/login.phtml%3F.done%3Dframeset.phtml&ref=https%3A//www.intacct.com/ia/acct/login.phtml%3F.done%3Dframeset.phtml&random=3619079888, type=Other, willNavigate=true, isMainFrame=false 
[debug] [phantom] Successfully injected Casper client-side utilities 
[info] [phantom] Done 4 steps in 2821ms 

ответ

1

Вопрос заключается в том, что сайт еще не загружен и не будет отображаться вошедшего странице. Попробуйте добавить свой casper.capture("screen.png"); внутри другого блока casper.then(), это заставит камеру захватить скриншот после того, как он получит ответ на запрос, вызванный вашими действиями. Может быть, есть лучший способ сделать это, но это сработало для меня несколько раз.

+0

Спасибо за ответ, я обновил код с вашим предложением, и я вставил результаты - захват по-прежнему остается на странице входа, а не на странице «приборной панели». – user4727947

Смежные вопросы