Консоль транспортира показывает отличается от консоли elementor
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
Что я делаю неправильно?
Я пробовал разные комбинации, но не работал.
я думаю, что это о выходе, поэтому, когда я делаю это
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.
1 ответ
Прежде всего транспортир асинхронный, так что если вы консоль журнала getText()
, это не даст текст, но обещание. Чтобы получить текст, вы должны использовать then function()
лайк:
taskPage.productCountInTask.getText().then(function(text){
console.log('yyyyy', text);
});