I have a problem performing a tap() on a button when testing with Detox.
<Button style={this._loginButtonDisabled() ? {} : styles.loginButtonActive}
disabled={this._loginButtonDisabled()}
onPress={this.logInClick}
testID='logInButton'>
<Text style={styles.loginButtonText}>Log In</Text>
</Button>
Our test looks like this:
const emailInput = element(by.id('emailInput'));
await emailInput.replaceText('idontexist#myeatclub.com');
const passwordInput = element(by.id('passwordInput'));
await passwordInput.replaceText('password');
await element(by.id('logInButton')).tap();
The button is visible all the time, but becomes enabled ('tappable') only after typing in the text in the form fields. So the code above taps the button before it's enabled, resulting in no real action. What I'd like to do is wait until button is enabled, and then perform the tap.
What's the suggested way of handling this type of scenario? I couldn't find any good examples in the docs.
I think it's because you are using replaceText
Instead try using typeText
Like this:
const emailInput = element(by.id('emailInput'));
await emailInput.replaceText('idontexist#myeatclub.com');
const passwordInput = element(by.id('passwordInput'));
// \n is used to press the return key on keyboard
await passwordInput.typeText('password\n');
await element(by.id('logInButton')).tap();
Related
I was wondering if it is possible to add a message instead of showing the values when the interactions tests are run in storybook.
for example:
FilledForm.play = async ({ canvasElement }) => {
const buttonEl = getByRole('button')
await expect(buttonEl.textContent).toContain('some button text');
//this gives `expect('some button text').toContain('some button text')`
//would have been better if it gave: `expect textContent to contain 'some button text'`;
any clue if that is possible? FYI it is not a deal breaker for me, it a cheaper alternative to have the test-runner and it works on a case by case, just want to know if there is a way to put extra message when showing the test result.
Ran into the issue, where the test code should click the button Process in the iframe. Used npm i cypress-iframe lib, but came up to nothing. Cypress could not find the button.
Tried cy.iframe('[class="resp-iframe"]').find('resp-iframe[id="submit"]')
HTML of the problem
Tried the other ways to click on iframe button:
cy.get('iframe[class="resp-iframe"]').then($element => {
const $body = $element.contents().find('body')
cy.wrap($body).find('resp-iframe[class="btn btn-block btn-primary"]').eq(0).click();
})
also
cy.get('[class="resp-iframe"]').then($element => {
const $body = $element.contents().find('body')
let stripe = cy.wrap($body)
stripe.find('[class="resp-iframe"]').click(150,150)
})
and
cy.iframe('#resp-iframe').find('[name="submitButton"]')
Error
Error 2
Updated FYI:
The first part of code - clicking the Google button in bottom-right:
const getIframeBody = () => {
// get the iframe > document > body
// and retry until the body element is not empty
return cy
.get('[id="popup-contentIframe"]')
.its('0.contentDocument.body')
// wraps "body" DOM element to allow
// chaining more Cypress commands, like ".find(...)"
// https://on.cypress.io/wrap
.then(cy.wrap)
}
getIframeBody().find('[id="payWithout3DS"]').click()
Then, waiting for secure payment preloader to finish up:
cy.wait(20000)
Then, trying to catch the Process button by suggestions:
cy.iframe('[name="AcsFrame"]').find('#submit').click()
or
cy.iframe('[class="resp-iframe"]').find('[id="submit"]')
whole code part looks:
const getIframeBody = () => {
// get the iframe > document > body
// and retry until the body element is not empty
return cy
.get('[id="popup-contentIframe"]')
.its('0.contentDocument.body')
// wraps "body" DOM element to allow
// chaining more Cypress commands, like ".find(...)"
// https://on.cypress.io/wrap
.then(cy.wrap)
}
getIframeBody().find('[id="payWithout3DS"]').click()
cy.wait(20000)
cy.iframe('[name="AcsFrame"]').find('#submit').click()
But still, getting:
Maybe anyone had something like that?
Thanks.
How about you try this:
cy.iframe('[name="AcsFrame"]').find('#submit').click()
You don't need to repeat the resp-iframe inside the .find().
The selector .find('resp-iframe[id="submit"]') means look for HTML like this: <resp-iframe id="submit"> but the element you want is <input id="submit">.
Everything else looks ok
cy.iframe('[class="resp-iframe"]').find('[id="submit"]')
I am creating an extension in VSCode that will close all open text documents when you click the option "Yes" in the vscode.window.showInformationMessage("Want to close?", "Yes", "No).
Pressing the "Yes" button will work fine but I want the "Enter" key on the keyboard to do the same? How can I listen for keystrokes when I register a command? Is it possible?
Here is my code right now:
context.subscriptions.push(
vscode.commands.registerCommand(
"close-tabs",
async (inputValue?: string) => {
const { activeTextEditor } = vscode.window;
if (!activeTextEditor) {
vscode.window.showInformationMessage("No active text editor");
return;
}
const answer = await vscode.window.showInformationMessage("Want to close tabs?", "Yes", "No");
if (answer === "Yes") {
vscode.commands.executeCommand("openEditors.closeAll");
}
// ON_ENTER: I was thinking an if case here that checks if enter has been pressed and also executes the command above?
}
)
);
To reiterate. How can I choose the "Yes" option when pressing the "Enter" key?
Since your InformationMessage box is not modal, it doesn't get focus when it appears.
I'm afraid you would have to make it modal - which in your case might be acceptable - to get the behaviour you want:
const answer = await vscode.window.showInformationMessage("Want to close tabs?", { modal: true }, "Yes", "No");
Then the message box's first button is automatically given focus and Enter will trigger it.
I found some information on CKEditor4 on trapping a clicked tool on the CKEditor toolbar but the v5 rewrite means this no longer works:
editor.on('afterCommandExec', handleAfterCommandExec);
function handleAfterCommandExec(event)
{
var commandName = event.data.name;
// For 'bold' commmand
if (commandName == 'bold')
alert("Bold button pressed!");
}
Are there any examples of working CKEditor 5 code to detect when a tool has been clicked? I'm actually trying to trap when someone clicks Track Changes to show the changes sidebar but hide it otherwise.
Maybe this works
const command = editor.commands.get('bold')
command.on('execute', () => {
console.log('Bold has been executed')
})
I have disabled right click by adding the following code. However, when I navigate from one page to other, during that window of time, on right click, the right click menu is opening.
document.onmousedown = function (event)
{
event = (event || window.event);
if (event.button == 2 )
{
alert("right click");
}
}
You can use oncontextmenu for this:
document.oncontextmenu = function () {return false;}
This can happen for case if document.onmousedown = function (event) isn't yet executed for some reason. Among reasons can be errors in java script or browser yet didn't execute document.onmousedown = function (event) because it is in process of executing some other javascript code.
Another proposal for consideration can be another way of disabling:
<body oncontextmenu="return false">