element.all(by.css('td[data-header-text="products"]')).first()
productCountInTask = taskPage.productCountInTask.getText();
console.log("yyyy",taskPage.productCountInTask.getText());
这是代码。
量角器控制台显示长文本
yyyy { ptor_:
{ setFileDetector: [Function],
launchApp: [Function],
controlFlow: [Function],
schedule: [Function],
getSession: [Function],
getCapabilities: [Function],
quit: [Function],
actions: [Function],
touchActions: [Function],
executeScript: [Function],
executeAsyncScript: [Function],
call: [Function],
wait: [Function],
sleep: [Function],
getWindowHandle: [Function],
getAllWindowHandles: [Function],
getPageSource: [Function],
close: [Function],
getCurrentUrl: [Function],
getTitle: [Function],
findElementInternal_: [Function],
findDomElement_: [Function],
findElementsInternal_: [Function],
takeScreenshot: [Function],
manage: [Function],
switchTo: [Function],
driver:
{ session_: [Object],
executor_: [Object],
flow_: [Object],
fileDetector_: null },
element: { [Function] all: [Function] },
'$': [Function],
'$$': [Function],
baseUrl: 'http://.qa..com:8080',
rootEl: 'body',
ignoreSynchronization: false,
getPageTimeout: 10000,
params: {},
ready:
{ closure_uid_815821442: 20,
flow_: [Object],
stack_: null,
parent_: null,
callbacks_: null,
state_: 'fulfilled',
handled_: true,
value_: null,
queue_: null },
plugins_:
{ pluginConfs: [],
pluginObjs: [],
assertions: {},
resultsReported: false },
resetUrl: 'data:text/html,<html></html>',
trackOutstandingTimeouts_: true,
mockModules_: [ [Object], [Object], [Object] ],
allScriptsTimeout: 240000,
getProcessedConfig: [Function],
forkNewDriverInstance: [Function],
restart: [Function] },
parentElementArrayFinder:
{ ptor_:
{ setFileDetector: [Function],
launchApp: [Function],
controlFlow: [Function],
schedule: [Function],
getSession: [Function],
getCapabilities: [Function],
quit: [Function],
actions: [Function],
touchActions: [Function],
executeScript: [Function],
executeAsyncScript: [Function],
call: [Function],
wait: [Function],
sleep: [Function],
getWindowHandle: [Function],
getAllWindowHandles: [Function],
getPageSource: [Function],
close: [Function],
getCurrentUrl: [Function],
getTitle: [Function],
findElementInternal_: [Function],
findDomElement_: [Function],
findElementsInternal_: [Function],
takeScreenshot: [Function],
manage: [Function],
switchTo: [Function],
driver: [Object],
element: [Object],
'$': [Function],
'$$': [Function],
baseUrl: 'http://.qa..com:8080',
rootEl: 'body',
ignoreSynchronization: false,
getPageTimeout: 10000,
params: {},
ready: [Object],
plugins_: [Object],
resetUrl: 'data:text/html,<html></html>',
trackOutstandingTimeouts_: true,
mockModules_: [Object],
allScriptsTimeout: 240000,
getProcessedConfig: [Function],
forkNewDriverInstance: [Function],
restart: [Function] },
getWebElements: [Function],
actionResults_:
{ closure_uid_815821442: 7800,
flow_: [Object],
stack_: null,
parent_: [Object],
callbacks_: null,
state_: 'pending',
handled_: false,
value_: undefined,
queue_: null },
locator_:
{ using: 'css selector',
value: 'td[data-header-text="products"]' } },
then: [Function],
elementArrayFinder_:
{ ptor_:
{ setFileDetector: [Function],
launchApp: [Function],
controlFlow: [Function],
schedule: [Function],
getSession: [Function],
getCapabilities: [Function],
quit: [Function],
actions: [Function],
touchActions: [Function],
executeScript: [Function],
executeAsyncScript: [Function],
call: [Function],
wait: [Function],
sleep: [Function],
getWindowHandle: [Function],
getAllWindowHandles: [Function],
getPageSource: [Function],
close: [Function],
getCurrentUrl: [Function],
getTitle: [Function],
findElementInternal_: [Function],
findDomElement_: [Function],
findElementsInternal_: [Function],
takeScreenshot: [Function],
manage: [Function],
switchTo: [Function],
driver: [Object],
element: [Object],
'$': [Function],
'$$': [Function],
baseUrl: 'http://.qa..com:8080',
rootEl: 'body',
ignoreSynchronization: false,
getPageTimeout: 10000,
params: {},
ready: [Object],
plugins_: [Object],
resetUrl: 'data:text/html,<html></html>',
trackOutstandingTimeouts_: true,
mockModules_: [Object],
allScriptsTimeout: 240000,
getProcessedConfig: [Function],
forkNewDriverInstance: [Function],
restart: [Function] },
getWebElements: [Function],
actionResults_:
{ closure_uid_815821442: 7800,
flow_: [Object],
stack_: null,
parent_: [Object],
callbacks_: null,
state_: 'pending',
handled_: false,
value_: undefined,
queue_: null },
locator_:
{ using: 'css selector',
value: 'td[data-header-text="products"]' } } }
bt 当我在 elementor 控制台中执行此操作时,它显示 2 作为输出。(它是一个单元格,我想要 cel 值,它是 2)
element.all(by.css('td[data-header-text="products"]')).first().getText() 2
我究竟做错了什么?
我尝试了不同的组合,但 dd 不起作用。
我认为这是关于输出所以当我这样做时
expect(element.all(
by.css('td[data-header-text="products"]')).first().getText()).toBe(1);
它说
Expected '1' to be 1.
我认为这是因为它是字符串,所以我曾经Number
转换为 int 但没有工作
Expected NaN to be 1.
它说
expect(Number(element.all(by.css('td[data-header-text="products"]')).first().getText())).toBe(1);
那么该怎么办
也为
var a = parseInt(element.all(by.css('td[data-header-text="products"]')).first().getText());
//checking if there is only one product
expect(a).toBe(1);
说
Expected NaN to be 1.