小编qui*_*eam的帖子

AFNetworking 3.0 和 SSL 身份验证与 setSessionDidReceiveAuthenticationChallengeBlock

我正在尝试从 AFNetworking 2.0 迁移到 3.0。

在以前的版本中,我将创建一个 AFHTTPRequestOperation 并在另一个块中使用 setWillSendRequestForAuthenticationChallengeBlock 处理客户端 SSL 身份验证。

例如:

[operation setWillSendRequestForAuthenticationChallengeBlock:^(NSURLConnection *connection, NSURLAuthenticationChallenge *challenge) {
    if ([challenge previousFailureCount] > 0) {
        //this will cause an authentication failure
        [[challenge sender] cancelAuthenticationChallenge:challenge];
        return;
    }

    //this is checking the server certificate
    if ([challenge.protectionSpace.authenticationMethod isEqualToString:NSURLAuthenticationMethodServerTrust]) {

        SecTrustResultType result;
        //This takes the serverTrust object and checkes it against your keychain
        SecTrustEvaluate(challenge.protectionSpace.serverTrust, &result);
Run Code Online (Sandbox Code Playgroud)

有人可以向我展示如何使用 AFHTTPSessionManager 执行此操作的示例吗?

我是否需要使用 AFURLSessionManager 发出请求?我确实在那里看到了一个块方法:

(void)setSessionDidReceiveAuthenticationChallengeBlock:(nullable NSURLSessionAuthChallengeDisposition (^)(NSURLSession *session, NSURLAuthenticationChallenge *challenge, NSURLCredential * _Nullable __autoreleasing * _Nullable credential))block

ssl ios afnetworking-3

5
推荐指数
1
解决办法
3174
查看次数

在 Selenium WebDriverJS 中获取 WebElement 的 HTML 源

那里有一个类似的问题(Python 中的一个较旧的问题),但这个问题与 JS 有关。在 NodeJS、Mocha 环境中使用 Selenium 进行测试。我想做的是单击 Bootstrap 下拉列表并检查 HTML 以查找更改。我尝试过以下方法:

test.it('should click on all header links',
function() {
    var elem = driver.findElement(By.id('Profile'));
    console.log(elem.getAttribute('innerHTML'));
    console.log(elem.getInnerHtml());
});
Run Code Online (Sandbox Code Playgroud)

两个调用都返回相同的内容。

{ then: [Function: then],
  cancel: [Function: cancel],
  isPending: [Function: isPending] }
Run Code Online (Sandbox Code Playgroud)

我计划将 HTML 提供给cheerio,以便我可以检查结构更改。感谢对此的任何帮助。

javascript selenium selenium-webdriver

3
推荐指数
1
解决办法
5213
查看次数