我是新來的量角器。無法在控制檯日誌中打印定位器(webelement)
我聲明瞭一個元素作爲變量,如:
txtSearch : element(by.xpath('//input[@type="search"]')),
在某些時候,我想記錄的定位:
var clickOn = function(webElement)
{
webElement.click();
console.log("Successfully clicked on the " + webElement);
};
我打電話從規格此功能類似的文件 - clickOn (txtSearch)
在Console.log
我越來越喜歡 - Successfully clicked on the [object Object]
。
請在下面找到所需的詳細信息:
節點版本:7.5.0
量角器版本:5.1.1
器瀏覽器:Chrome的
量角器配置文件:
exports.config = {
capabilities: {
browserName: 'chrome',
},
onPrepare: function(){
jasmine.getEnv().addReporter(reporter);
global.isAngularSite = function(flag) {
browser.ignoreSynchronization = !flag;
};
browser.manage().timeouts().setScriptTimeout(60000);
browser.driver.manage().window().maximize();
},
seleniumServerJar: '../../protractor/selenium/selenium-server-standalone-2.52.0.jar',
chromeDriver: '../../protractor/selenium/chromedriver_2.27.exe',
directConnect: true,
framework: 'jasmine2',
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['../PoC_Protractor/spec.js'],
jasmineNodeOpts: {
showColors: true,
defaultTimeoutInterval: 600000,
isVerbose: true
}
我試着用webElement.locator().toString()
但throwing-
失敗:webElement.locator不是一個函數
請您檢查我的答案在.. toString()應該工作..你可以更新與你在那個前面嘗試的問題 – AdityaReddy
[量角器控制檯日誌]的可能重複(http://stackoverflow.com/questions/19941739/protractor-console-log) – Xotabu4
[如何在量角器中打印webelement?]的可能的副本(http://stackoverflow.com/questions/42267387/how-to-print-the-webelement-in-massractor) –