首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >有没有办法让testcafe使用sso登录?

有没有办法让testcafe使用sso登录?
EN

Stack Overflow用户
提问于 2019-10-23 20:02:51
回答 1查看 763关注 0票数 4

对于端到端测试,我希望Testcafe使用单点登录到我们的SaaS应用程序(就像用户一样)。为此,Testcafe需要通过我们的代理,然后使用当前登录的用户的凭据登录到应用程序。

每当我使用自己的浏览器做这件事时,它都能很好地工作,但不知何故,Testcafe在试图访问页面时被卡住了。

我尝试过使用Testcafe提供的授权选项来实现这一点,但是,这些选项似乎都不起作用。

代码语言:javascript
复制
import { Selector, ClientFunction } from 'testcafe';

const getLocation = ClientFunction(() => document.location.href);

fixture("Close ADFS")
    .httpAuth({
      username: 'username',
      password: 'password'
    });

test('My first test', async t => {
  await t
    .navigateTo("url of web application")
    .expect(getLocation()).contains("url of web application")
    .expect(Selector("css selector that is in the application").exists).ok("Application not reached")
});

每当我运行测试时,我都会得到以下错误:

代码语言:javascript
复制
× My first test

1) AssertionError: expected 'about:error' to include 'url of web application'

Browser: Chrome 77.0.3865 / Windows 10.0.0

   9 |    });
  10 |
  11 |test('My first test', async t => {
  12 |  await t
  13 |    .navigateTo("url of web application")
> 14 |    .expect(getLocation()).contains("url of web application")
  15 |    .expect(Selector("css selector that is in the application").exists).ok("Application not reached")
  16 |});

at contains (C:\Users\M63G736\Projects\testcafe-adfs\test.js:14:28)
at <anonymous> (C:\Users\M63G736\Projects\testcafe-adfs\test.js:11:1)
at <anonymous> (C:\Users\M63G736\Projects\testcafe-adfs\node_modules\testcafe\src\api\wrap-test-function.js:17:28)
at TestRun._executeTestFn (C:\Users\M63G736\Projects\testcafe-adfs\node_modules\testcafe\src\test-run\index.js:289:19)
at TestRun.start (C:\Users\M63G736\Projects\testcafe-adfs\node_modules\testcafe\src\test-run\index.js:338:24)


2) A request to "url of web application" has failed.
Use quarantine mode to perform additional attempts to execute this test.
You can find troubleshooting information for this issue at "https://go.devexpress.com/TestCafe_FAQ_ARequestHasFailed.aspx".

Error details:
Failed to find a DNS-record for the resource at "url of web application".

Browser: Chrome 77.0.3865 / Windows 10.0.0

有没有人能说出这是不是可以用Testcafe做的事情?如果是这样,你能告诉我应该使用什么配置/代码吗?

编辑:我通过使用另一个代理修复了DNS错误。并对测试进行了一些修改:

代码语言:javascript
复制
import { Selector, ClientFunction } from 'testcafe';

const getLocation = ClientFunction(() => document.location.href);

fixture("Close ADFS").page('https://google.nl');

test('My first test', async t => {
  await t
    .navigateTo("url of web application")
    .expect(Selector("element on homepage of web application").exists).ok("Close not reached")
    .expect(getLocation()).contains("url of web application")
});

这仍然失败,在

代码语言:javascript
复制
 Close ADFS
 × My first test

   1) AssertionError: Close not reached: expected false to be truthy

      Browser: Chrome 77.0.3865 / Windows 10.0.0

          9 |  });
         10 |
         11 |test('My first test', async t => {
         12 |  await t
         13 |    .navigateTo("url of web application")
       > 14 |    .expect(Selector("body > app-component > app-shell > header > nav > div > div.navbar-header > div").exists).ok("Close not reached")
         15 |    .expect(getLocation()).contains("url of web application")
         16 |});

         at ok (C:\Users\M63G736\Projects\testcafe-adfs\test.js:14:113)
         at <anonymous> (C:\Users\M63G736\Projects\testcafe-adfs\test.js:11:1)
         at <anonymous> (C:\Users\M63G736\Projects\testcafe-adfs\node_modules\testcafe\src\api\wrap-test-function.js:17:28)
         at TestRun._executeTestFn (C:\Users\M63G736\Projects\testcafe-adfs\node_modules\testcafe\src\test-run\index.js:289:19)
         at TestRun.start (C:\Users\M63G736\Projects\testcafe-adfs\node_modules\testcafe\src\test-run\index.js:338:24)



 1/1 failed (22s)
npm ERR! Test failed.  See above for more details.

每当我运行测试时,我看到它确实访问了google.nl,但随后无法导航到应用程序URL。

EN

回答 1

Stack Overflow用户

发布于 2019-10-24 20:04:04

这意味着浏览器不能加载“web应用程序的URL”URL。确保可以从执行测试的计算机访问web应用程序。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58522445

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档