Reputation: 324
i have defined a testsped with orders a product from a shop. At the end of the process you will be redirected to the payment provider (paypal or else) to pay your order. Here is the problem: The shop is based on angular but not the payment page. The test is running until i get to the payment page. Then i receive:
Failed: {"errorMessage":"Unable to find element with xpath '//*[@id=\"cardnumber\"]'
The code is this:
it('submit the order', function () {
CO4.order();
browser.sleep(8000);
});
it('enters the creditcard data', function () {
browser.driver.findElement(by.xpath('//*[@id="cardnumber"]')).sendKeys("123456789");
browser.driver.findElement(by.xpath('//*[@id="expmonth"]')).sendKeys("12");
browser.driver.findElement(by.xpath('//*[@id="expyear"]')).sendKeys("2050");
browser.driver.findElement(by.xpath('//*[@id="cvm"]')).sendKeys("123");
browser.driver.findElement(by.xpath('//*[@id="next"]')).click();
});
The config is:
var TIMEOUT = 40000;
exports.config = {
seleniumServerJar: '../../selenium/selenium-server-standalone-2.48.2.jar',
baseUrl: 'https://myShop/main',
specs: [
'./UseCases/protractorSuiteCheckout.js',
],
capabilities: {
'browserName': 'PhantomJS'.toLowerCase(),
'phantomjs.binary.path': require('phantomjs').path,
'phantomjs.cli.args': ['--ignore-ssl-errors=true', '--web-security=false'],
'phantomjs.ghostdriver.cli.args': ['--loglevel=DEBUG']
},
getPageTimeout: TIMEOUT,
allScriptsTimeout: TIMEOUT,
jasmineNodeOpts: {
defaultTimeoutInterval: TIMEOUT,
isVerbose: true,
includeStackTrace: true
},
framework: "jasmine2",
onPrepare: function () {
browser.driver.manage().window().maximize();
browser.driver.manage().deleteAllCookies();
var jasmineReporters = require('jasmine-reporters');
jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
consolidateAll: true,
filePrefix: 'xmloutput',
savePath: 'report'
}));
}
};
Please help!
Upvotes: 0
Views: 459
Reputation: 2953
Why using complicated xpath when all you are doing is a findById ?
replace
browser.driver.findElement(by.xpath('//*[@id="cardnumber"]')).sendKeys("123456789");
browser.driver.findElement(by.xpath('//*[@id="expmonth"]')).sendKeys("12");
browser.driver.findElement(by.xpath('//*[@id="expyear"]')).sendKeys("2050");
browser.driver.findElement(by.xpath('//*[@id="cvm"]')).sendKeys("123");
browser.driver.findElement(by.xpath('//*[@id="next"]')).click();
by :
browser.driver.findElement(by.id('cardnumber')).sendKeys("123456789");
browser.driver.findElement(by.id('expmonth')).sendKeys("12");
browser.driver.findElement(by.id('expyear')).sendKeys("2050");
browser.driver.findElement(by.id('cvm')).sendKeys("123");
browser.driver.findElement(by.id('next')).click();
See if it works better ?
Upvotes: 1