gpt4 book ai didi

angularjs - 将 angularjs e2e 测试转换为 Protractor 的浏览器对象

转载 作者:行者123 更新时间:2023-12-04 14:28:18 27 4
gpt4 key购买 nike

这是来自 angularjs e2e 测试的一些代码。

expect(browser().location().url()).toBe('/phones');

Protractor 给出这个错误。

TypeError: Property 'browser' of object # is not a function



特别是,如何更改线以修复 Protractor 错误?
一般来说,在哪里可以找到有关 webdriverjs 浏览器对象的文档?

最佳答案

您可以使用:

//using full URL
expect(browser.getCurrentUrl()).toEqual('http://host:port/your/url/phones');

//or using baseUrl
expect(browser.getCurrentUrl()).toEqual(browser.baseUrl + '/phones');

您可以找到 API here .

这就是我在使用 console.log(browser); 时得到的结果:
{ controlFlow: [Function],
schedule: [Function],
getSession: [Function],
getCapabilities: [Function],
getCapability: [Function],
quit: [Function],
actions: [Function],
executeScript: [Function],
executeAsyncScript: [Function],
call: [Function],
wait: [Function],
sleep: [Function],
getWindowHandle: [Function],
getAllWindowHandles: [Function],
getPageSource: [Function],
close: [Function],
getCurrentUrl: [Function],
getTitle: [Function],
findDomElement_: [Function],
takeScreenshot: [Function],
manage: [Function],
navigate: [Function],
switchTo: [Function],
driver:
{ session_:
{ then: [Function: then],
cancel: [Function: cancel],
isPending: [Function: isPending] },
executor_: { execute: [Function] },
flow_:
{ events_: {},
timer: [Object],
history_: [],
activeFrame_: [Object],
schedulingFrame_: [Object],
eventLoopId_: [Object] } },
element: { [Function] all: [Function] },
'$': [Function],
'$$': [Function],
baseUrl: 'http://localhost:8000',
rootEl: 'body',
ignoreSynchronization: false,
params: {},
moduleNames_: [],
moduleScripts_: [] }

关于angularjs - 将 angularjs e2e 测试转换为 Protractor 的浏览器对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22057584/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com