0

我希望我的量角器测试打开https://www.jetblue.com/并单击往返。下面是我为此编写的一段代码:

describe('This test suite will validate booking related features', function(){

    beforeAll(function(){
        browser.driver.manage().window().maximize();
        browser.ignoreSynchronization=true;
        browser.waitForAngularEnabled(false);
        jasmine.DEFAULT_TIMEOUT_INTERVAL = 100000;

    })

    beforeEach(function(){
        browser.get('https://www.jetblue.com/');
        browser.getTitle().then(function(text){
            console.log("Title of the page is : " +text);
        });
    });

    it('Customer can search for Flights for One Way Trip', function(){

        var AllElements = element.all(by.xpath("//label[text()=' One-way ']/parent::jb-radio"));

        AllElements.each(function(ele){
            ele.click();
            browser.sleep(10000);
        });

    });

});

测试成功通过,无需选择单选按钮。我使用 Selenium-Java 使用相同的定位器,测试实际上是在执行操作并通过。让我觉得哪个更好,因为 Selenium-Java 在 Angular 应用程序上也同样有效。

4

1 回答 1

0

“往返”单选按钮似乎是这个元素 <div _ngcontent-c47="" class="marker ba b--transparent bg-core-blue t-vfast"></div>

所以我会尝试使用这个定位器: element(by.css('.marker.ba.b--transparent.bg-core-blue.t-vfast'));

于 2019-10-03T15:34:34.397 回答