Login 使用Phantomjs 2.0登录salesforce.com,继续询问验证码
我们正在进行一些测试,以使用Phantomjs 2.0连接到salesforce.com。 它工作得很好,但在过去的几周里,salesforce.com一直在要求每次新的会话都提供验证码Login 使用Phantomjs 2.0登录salesforce.com,继续询问验证码,login,phantomjs,salesforce,verification,Login,Phantomjs,Salesforce,Verification,我们正在进行一些测试,以使用Phantomjs 2.0连接到salesforce.com。 它工作得很好,但在过去的几周里,salesforce.com一直在要求每次新的会话都提供验证码 是否有人遇到同样的问题?您可以将您的IP地址列入白名单,以阻止Salesforce询问验证码。 转到设置->安全->网络访问并将您的IP添加到白名单 这也许应该是一个评论,但由于我没有必要的评论点,请原谅“答案”。这是一个有效的答案,因为我对casper/phantom不是很精通,我将更新尝试的解决方案。希望我
是否有人遇到同样的问题?您可以将您的IP地址列入白名单,以阻止Salesforce询问验证码。 转到设置->安全->网络访问并将您的IP添加到白名单
这也许应该是一个评论,但由于我没有必要的评论点,请原谅“答案”。这是一个有效的答案,因为我对casper/phantom不是很精通,我将更新尝试的解决方案。希望我的尝试能帮助其他人 有人遇到过同样的问题吗 A:是的 问题:自从新浏览器登录SF时起,SF使用验证码对用户进行身份验证(可使用新浏览器如firefox进行测试)。奇怪的是,这个问题并没有在一次匿名会议上重现 建议的解决方案:创建一个cookie文件并使用casper/phantom脚本登录到SF。将身份验证保存到JS cookies文件,否则每个登录都需要验证 测试步骤:
var fs = require('fs'); //top of script
var html = this.getHTML(); //place this in wait_function() after login()
fs.write('./output.html', html, 'w');
this.click('phSearchInput', function () { //'phSearchInput' found in above extract
this.fill('form', {
'phSearchInput' : '*verification_number_here*'
}, true);
2.1验证后的最终重定向似乎存在问题。我不确定我能给这个花多少时间(因为这不是一个优先事项),我对JS还很陌生。我将把代码留在这里供参考/测试
/*Altered from http://blog.deadlypenguin.com/blog/2013/07/09/logging-into-salesforce-with-casperjs/ */
var LOGIN_URL, LOGIN_USERNAME, LOGIN_PASSWORD, casp;
casp = require('casper').create({
viewportSize: {
width: 1024,
height: 768
},
verbose: true,
logLevel: 'debug'
});
casp.userAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_5) AppleWebKit/537.4 (KHTML, like Gecko) Chrome/22.0.1229.94 Safari/537.4');
if (!casp.cli.has('username') && !casp.cli.has('password')) {
casp.echo('Usage: $ casperjs sfdclogin.casper.js --username=USERNAME --password=PASSWORD [--prod]').exit(-1);
}
if (casp.cli.has('prod')) {
LOGIN_URL = 'https://test.salesforce.com//';
} else {
LOGIN_URL = 'https://test.salesforce.com/';
}
LOGIN_USERNAME = casp.cli.get('username');
LOGIN_PASSWORD = casp.cli.get('password');
casp.start(LOGIN_URL, function () {
this.log('Logging in', 'debug');
//login
this.fill('form', {
'username': LOGIN_USERNAME,
'pw': LOGIN_PASSWORD
}, true);
this.log('Logged in', 'debug');
});
casp.wait(5000, function () {
this.log('Varification START', 'debug');
this.fill('form', {
'emc': '*verification_number_here*'
}, true);
this.captureSelector('test.png', 'html');
this.log('Varification FINISHED', 'debug');
this.wait(6000)
}, 12000);
casp.then(function () {
//casp.waitForUrl('https://cs31.salesforce.com/home/home.jsp', function() {
this.log('Are we logged in??');
this.captureSelector('test2.png', 'html');
}, 12000);
casp.run();
你检查过他们允许这样的事情吗?此外,“有人经历过同样的问题吗?”不是一个特别有用的问题。您实际的编程问题是什么?我们在Salesforce.com上使用Phantomjs 2.0运行selenium脚本时遇到问题。每次在本地运行脚本时,我们都会看到验证屏幕。不幸的是,由于安全策略,这不是我们的选项。