<small id='QzF3o'></small><noframes id='QzF3o'>

      <legend id='QzF3o'><style id='QzF3o'><dir id='QzF3o'><q id='QzF3o'></q></dir></style></legend>
        • <bdo id='QzF3o'></bdo><ul id='QzF3o'></ul>
        <tfoot id='QzF3o'></tfoot>

        <i id='QzF3o'><tr id='QzF3o'><dt id='QzF3o'><q id='QzF3o'><span id='QzF3o'><b id='QzF3o'><form id='QzF3o'><ins id='QzF3o'></ins><ul id='QzF3o'></ul><sub id='QzF3o'></sub></form><legend id='QzF3o'></legend><bdo id='QzF3o'><pre id='QzF3o'><center id='QzF3o'></center></pre></bdo></b><th id='QzF3o'></th></span></q></dt></tr></i><div id='QzF3o'><tfoot id='QzF3o'></tfoot><dl id='QzF3o'><fieldset id='QzF3o'></fieldset></dl></div>

        如何用量角器测试 html 链接?

        时间:2023-06-15
          <tbody id='LoGxp'></tbody>

      1. <tfoot id='LoGxp'></tfoot>

            <i id='LoGxp'><tr id='LoGxp'><dt id='LoGxp'><q id='LoGxp'><span id='LoGxp'><b id='LoGxp'><form id='LoGxp'><ins id='LoGxp'></ins><ul id='LoGxp'></ul><sub id='LoGxp'></sub></form><legend id='LoGxp'></legend><bdo id='LoGxp'><pre id='LoGxp'><center id='LoGxp'></center></pre></bdo></b><th id='LoGxp'></th></span></q></dt></tr></i><div id='LoGxp'><tfoot id='LoGxp'></tfoot><dl id='LoGxp'><fieldset id='LoGxp'></fieldset></dl></div>
              <bdo id='LoGxp'></bdo><ul id='LoGxp'></ul>

                • <legend id='LoGxp'><style id='LoGxp'><dir id='LoGxp'><q id='LoGxp'></q></dir></style></legend>

                  <small id='LoGxp'></small><noframes id='LoGxp'>

                  本文介绍了如何用量角器测试 html 链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我是量角器的新手,想测试链接是否有效.我了解尝试获取元素 ID,但我应该期望链接等于什么?

                  I am new to protractor and would like to test if a link is working. I understand trying to get the element id but what should i expect that the link equals?

                  还有人有关于示例量角器测试的任何好的文档吗?我已经通过这个 http://angular.github.io/protractor/#/tutorial 这很有帮助,但我需要更多我可以做的可能测试的例子.

                  Also has anyone got any good documentation on example protractor tests? I have been through this http://angular.github.io/protractor/#/tutorial which was helpful but i need more example of possible tests I could do.

                  到目前为止我有这个:

                  it('should redirect to the correct page', function(){
                          element(by.id('signmein').click();
                          expect(browser.driver.getCurrentUrl()).toEqual("http://localhost:8080/web/tfgm_customer/my-account");
                      });
                  

                  推荐答案

                  想测试链接是否正常

                  would like to test if a link is working

                  这有点宽泛 - 它可能意味着链接具有适当的 href 属性,或者单击链接后应该打开一个新页面.

                  This is a bit broad - it could mean the link to have an appropriate hrefattribute, or that after clicking a link there should be a new page opened.

                  要检查 href 属性,请使用 getAttribute():

                  To check the href attribute, use getAttribute():

                  expect(element(by.id('myLink')).getAttribute('href')).toEqual('http://myUrl.com');
                  

                  <小时>

                  要点击链接,请使用 click(),要检查当前 URL,请使用 getCurrentUrl():

                  element(by.id('myLink').click();
                  expect(browser.getCurrentUrl()).toEqual("http://myUrl.com");
                  

                  注意,如果点击后打开的是非角页面,则需要玩转ignoreSynchronization标志,见:

                  Note that if there is a non-angular page opened after the click, you need to play around with ignoreSynchronization flag, see:

                  • 点击后打开的非角度页面

                  如果链接在新标签页中打开,您需要切换到该窗口,检查 URL,然后切换回主窗口:

                  If the link is opened in a new tab, you need to switch to that window, check the URL and then switch back to the main window:

                  element(by.id('myLink')).click().then(function () {
                      browser.getAllWindowHandles().then(function (handles) {
                          browser.switchTo().window(handles[handles.length - 1]).then(function () {
                              expect(browser.getCurrentUrl()).toEqual("http://myUrl.com");
                          });
                  
                          // switch back to the main window
                          browser.switchTo().window(handles[0]);
                      });
                  });
                  

                  这篇关于如何用量角器测试 html 链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何将焦点设置在我网页的某个部分然后向下滚动 下一篇:搜索同级时使用 CSS 选择器而不是 XPath 定位器

                  相关文章

                  1. <tfoot id='7wLes'></tfoot>
                  2. <small id='7wLes'></small><noframes id='7wLes'>

                    <i id='7wLes'><tr id='7wLes'><dt id='7wLes'><q id='7wLes'><span id='7wLes'><b id='7wLes'><form id='7wLes'><ins id='7wLes'></ins><ul id='7wLes'></ul><sub id='7wLes'></sub></form><legend id='7wLes'></legend><bdo id='7wLes'><pre id='7wLes'><center id='7wLes'></center></pre></bdo></b><th id='7wLes'></th></span></q></dt></tr></i><div id='7wLes'><tfoot id='7wLes'></tfoot><dl id='7wLes'><fieldset id='7wLes'></fieldset></dl></div>
                      <bdo id='7wLes'></bdo><ul id='7wLes'></ul>

                  3. <legend id='7wLes'><style id='7wLes'><dir id='7wLes'><q id='7wLes'></q></dir></style></legend>