I tried:
$('body') << Keys.chord(Keys.CONTROL, "w") -
driver.close()
driver.findElement(By.cssSelector("body")).sendKeys(Keys.CONTROL +"w")
this is the code for the test:
def "scrape"() {
when:
ScrapeTestPage page = to ScrapeTestPage
then:
$("input", name: "search").value("test")
$("button", type: "submit").click()
$('td a', 0).click() //this opens a new tab
DetailsPage page1 = to DetailsPage
println "test"
//now I'd like to close that tab without closing the first one
}
I tried wrapping the new tab in withNewWindow but it throws an error:
withNewWindow({$('td a', 0).click()}){}
|
org.openqa.selenium.InvalidArgumentException: Expected "handle" to be a string, got [object Undefined] undefined
Related
I need to show a warning popup button when the user presses the "Checkout" button (just an ok/dismiss button)
I avoid using raise Warning() or raise ValidationError() since I want to remain on the existing page and simply show a pop-up warning.
Can you please share the simplest way to do this in Odoo 13?
On click proceed checkout button called jsonRpc where call your json controller with that add your custom logic on the controller and return that and on the js check with your condition and raise your Dialog-Box Like this,On Js:
var Dialog = require('web.Dialog');
ajax.jsonRpc("/custom/url", 'call', {}).then(function(data) {
if (data) {
var dialog = new Dialog(this, {
size: 'medium',
$content: _t("<div style='font-size:14px;font-family:Helvetica, Arial, sans-serif;'>Error.</div>"),
buttons: [{
text: _t('Ok'),
classes: "btn-primary",
close: true
}],
}).open();
} else {
// odoo logic
}
});
Thanks
How do i capture the error messages generated on web page(for example an error message generated when a login button is pressed without inserting any username or password), how do i extract this error message "Username is required" using geb.
im using geb groovy based automation
So you would first model your page, and get the locator for the error you want to assert has been displayed. Note that you want to set this to required: false as you would not expect it to be displayed when you first land on the page.
Page with example page error with ID of #pageError:
class MyPage extends Page
{
static url = "/mypageurl"
static at = {
title == "My Page"
}
static content = {
pageError (required: false) { $('#pageError') }
submitButton { $('#mySubmitButton') }
}
def submitForm() {
submitButton.click()
}
}
Then you have your test:
def "If I try click Submit without filling out all form details show me an error message"()
{
when: "I click Submit without completing all form fields"
def myPage = to(MyPage)
myPage.submitForm()
then: "I am shown an error message on the same page"
myPage.pageError.displayed
}
EDIT:
Noticed you mentioned getting the content of the error, you would call this instead to get the text:
myPage.pageError.text()
Using nightwatch.js how can I wait for an element to load without the result printing to the console?
I do not want waits to appear in my reports, only normal assertions.
The following code will output 'Waiting for settings menu to load' to the console. If no custom message is used, the default message is 'Element #editMenuContentsButton was visible after xxxx milliseconds':
/**Clicks the settings menu and logs the action.
* #method clickSettings
*/
clickSettings: function () {
this.waitForElementVisible('#settingsSettings', 5000, 'Waiting for settings menu to load');
this.click('#settingsSettings', function () {
testUtil.logAction('Click Gallery settings menu');
});
this.api.pause(1000);
return this;
}
I found a solution to this by simply commenting out the following code in the waitForElement.js file (found in: lib/api/element-commands)
WaitForElement.prototype.pass = function(result, defaultMsg, timeMs) {
this.message = this.formatMessage(defaultMsg, timeMs);
//this.client.assertion(true, null, null, this.message, this.abortOnFailure);
return this.complete(result);
};
I am facing issues while pressing different buttons on message-boxes on JavaScript views of my SAPUI5 application. Other item seems to work fine like inserting text in text boxes, pressing buttons, selecting a row of table, etc.
I found out that every messagebox has a type/class like sapMDialogSuccess or sapMDialogError or sapMDialogWarning, etc. Do we have a similar type/class for OK, Cancel, Abort buttons (displayed on MessageBox)?
I am able to get exact text which appears on my MessageBox using:
ok(true, "This success message is displayed:- " +
sap.ui.test.Opa5.getJQuery()(".sapMDialogSuccess").
find(".sapMText").text());
But when I try following code to select (and then press) OK button, it does not work. Here is the code I am using:
//OK Button - Find & Press OK button
Then.waitFor({
pollingInterval: 5,
searchOpenDialogs: true,
controlType: "sap.m.Button",
check: function(aButton) {
if (aButton.text() === "OK") {
return !!sap.ui.test.Opa5.getJQuery()(".sapMDialogSuccess").length;
}
},
success: function() {
ok(true, "OK button found - SUCCESS");
},
errorMessage: "OK Button not found - ERROR"
});
Here is the error I am getting:
OK Button not found - ERROR
Callstack:
at Object.<anonymous> (http: //<<server>>:50000/XMII/CM/Opa-LineGroupMaintenance.html:152:22)
at Object.f (https:// sapui5.hana.ondemand.com/sdk/resources/sap/ui/test/opaQunit.js:6:331)
at Object.run (https:// sapui5.hana.ondemand.com/sdk/resources/sap/ui/thirdparty/qunit.js:11:9294)
at eval (https:// sapui5.hana.ondemand.com/sdk/resources/sap/ui/thirdparty/qunit.js:11:11222)
at C (https:// sapui5.hana.ondemand.com/sdk/resources/sap/ui/thirdparty/qunit.js:11:5918)
at E (https:// sapui5.hana.ondemand.com/sdk/resources/sap/ui/thirdparty/qunit.js:11:6299)
at eval (https:// sapui5.hana.ondemand.com/sdk/resources/sap/ui/thirdparty/qunit.js:11:6431)# 3618 ms
Expected:
true
Result:
false
Diff:
trufalse
Source:
at Object.eval [as ok] (https:// sapui5.hana.ondemand.com/sdk/resources/sap/ui/thirdparty/qunit.js:11:20688)
Script error.# 3623 ms
Source:
:0
It is working for me in this way. the Success Function we have to do firePress() event:
Then.onTheTranslationPage.ipressOKButton();
ipressOKButton: function () {
var oOrderNowButton = null;
return this.waitFor({
viewName: sViewName,
searchOpenDialogs: true, //mandatory
controlType: "sap.m.Button", //optional
success: function (aButtons) {
return aButtons.filter(function (oButton) {
if(oButton.getText() == "OK") {
oOrderNowButton = oButton;
oButton.firePress();
}
});
Opa5.assert.ok(true, "Form Got Submitted Successfully");
},
actions: new Press(),
errorMessage: "Did not find the dialog control"
});
},
I found following piece of code working for me:
Then.waitFor({
pollingInterval: 10, //optional
searchOpenDialogs: true, //mandatory
//controlType: "sap.m.Button", //optional
success: function(oDialogs) {
if (oDialogs[oDialogs.length - 1].$().text() === "OK") {
oDialogs[oDialogs.length - 1].$().trigger("click");
Opa5.assert.ok(true, "Found OK button inside open dialog!");
}
},
errorMessage: "Did not find either the open dialog or buttons inside an open dialog"
});
I have the following code:
Tabs {
Tab {
id: financialDetailsTab
title: i18n.tr("Financial Details")
page: Qt.resolvedUrl("FinancialDetails.qml")
}
Tab {
id: monthlyBudgetTab
title: i18n.tr("Monthly Budget")
page: Qt.resolvedUrl("MonthlyBudget.qml")
}
Tab {
id: annualBudgetTab
title: i18n.tr("Annual Budget")
page: Qt.resolvedUrl("AnnualBudget.qml")
}
Tab {
id: savingsGoalsTab
title: i18n.tr("Savings Goals")
page: Qt.resolvedUrl("SavingsGoals.qml")
}
}
which is generating the following errors:
Unable to assign QString to QQuickItem*
Unable to assign QString to QQuickItem*
Unable to assign QString to QQuickItem*
Unable to assign QString to QQuickItem*
on the lines where Qt::resolvedUrl is being used. The Tabs component is a part of the Ubuntu SDK, and not Qt Quick, and the only example of it's use doesn't provide much insight into the problem.
I've added the exact same lines as properties of the MainView, outside of the Tabs component, and the problem has not been evident there, leading me to believe the issue lies with the Ubuntu component. While the problem may be with the Ubuntu component, some help in understanding what the error message actually means would be helpful.
The error you are getting means that the 'page' property from Tab { } item can't accept a string (or url) content, it wants an Item or derived component.
So I'm pretty sure your AnnualBudget or SavingsGoals files can be instanciated as components, since they are in the same folder (so no import needed) and the file name first letter is uppercase so QML engine automatically allows you to do this :
Tabs {
Tab {
id: financialDetailsTab
title: i18n.tr("Financial Details")
page: financePage;
}
}
FinancialDetails {
id: financePage;
}
So 'financePage' is an ID, so for the QML engine it's a QQuickItem pointer and it will accept it.
Just do the same for each tab/page pair.