How to exec action typeText() with React Native TextInput outside screen (position: absolute, right: -99) - detox

I have TextInput outside screen with style {position: 'absolute', right: -99},
When i call action typeText(), i receive this error
"Error: Error: Cannot perform action due to constraint(s) failure.
Exception with Action: {
"Action Name" : "Tap",
"Element Description" : "",
"Failed Constraint(s)" : "interactable",
"All Constraint(s)" : "(!(isSystemAlertViewShown) && ((respondsToSelector(isAccessibilityElement) && isAccessibilityElement) || kindOfClass('UIView')) && (enabled && !(((kindOfClass('UIView') || respondsToSelector(accessibilityContainer)) && ancestorThatMatches(!(enabled))))) && interactable)",
"Recovery Suggestion" : "Adjust element properties so that it matches the failed constraint(s)."
}
[
{
"Description" : "Cannot perform action due to constraint(s) failure.",
"Error Domain" : "com.google.earlgrey.ElementInteractionErrorDomain",
"Error Code" : "1",
"File Name" : "GREYBaseAction.m",
"Function Name" : "-[GREYBaseAction satisfiesConstraintsForElement:error:]",
"Line" : "66"
}
]
"
How can i do execute action typeText() with React Native TextInput outside screen

In order for Detox to interact with an element, the element needs to pass visibility criteria. I think the standard is 75% visibility.
detox/docs/Introduction.WritingFirstTest.md
Note that the visibilty matcher makes sure the element is actually visible on screen (at least 75% of it to be exact). If it appears under the fold (eg. the user has to scroll to see it), this specific matcher will fail.
So in summary I don't see how it's possible to type text when the input field is outside the screen.

Related

How do I detect when my app crashes and send a firebase event at that time?

So I intend to detect and trigger a firebase custom event when my app crashes, is there a recommended way to check that? I tried AppDelegate method applicationWillTerminate but it didn't work, similarly I tried to observe through an NSSetUncaughtExceptionHandler but again in vain. I want to know how Crashlytics or Sentry or Bugsnag do it. Any help will be more than helpful.
Whenever app is crashed it means it doesnt respond to any of the events triggered or any calls you make in your app. So if it helps you can send event parameters in the Crash log event something like this.
let keysAndValues = [
"string key" : "string value",
"string key 2" : "string value 2",
"boolean key" : true,
"boolean key 2" : false,
"float key" : 1.01,
"float key 2" : 2.02
] as [String : Any]
Crashlytics.crashlytics().setCustomKeysAndValues(keysAndValues)
Refer : https://firebase.google.com/docs/crashlytics/customize-crash-reports for more details

vscode: how to make text after snippet *not* selected?

When a snippet (for whatever language) is triggered, and the cursor is moved to a tab-stop, the area is "selected" (that is, you are still in "snippet mode" where you can go to another tab-stop). But I would like to get out of this "snippet mode" (e.g not having the area selected after tab-stop), because it suppresses intellisense (the selected area after snippet was triggered accepts anything, so it does no longer suggest intellisense function, variables, etc. Is there a settings in vscode to disable this "selection" after snippet is triggered?
If you have only one tabstop you can use $0 to avoid the "selecttion".
But if you have more than one i don't think it's possible.
I don't believe that's possible.
Snippets often have placeholders such as ${1:name} to indicate what's expected in that tab stop.
Take this one for example:
"JS arrow function": {
"prefix": "af",
"body": [
"const ${1:name} = (${2:props}) => {",
"\t$3",
"}"
],
"description": "Create arrow function"
}
Using tab will cycle over $1, $2 and $3, and for $1 and $2 there is a placeholder.
You can omit the placeholders if you want:
"JS arrow function2": {
"prefix": "af2",
"body": [
"const $1 = ($2) => {",
"\t$3",
"}"
],
"description": "Create arrow function"
}
But instellisense won't work until you press escape.
You can add your own snippets globally or per language if you prefer to customise them and avoid placeholders.
See this link for more information.

Importing dynamic filenames into React-Native

I have a menu.json file with hundreds of items in it:
menu_items = [
{
name: "Category 1",
file: "cat1.json"
},
{
name: "Category 2",
file: "cat2.json"
},
{
name: "Category 3",
file: "cat3.json"
},
{
name: "Category 4",
file: "cat4.json"
},
{
name: "Category 5",
file: "cat15.json"
}
]
I am able to read the menu.json file. I then create a Scrollable List showing each of the entries. When a user clicks on the entry, I want to load another screen that imports the specified json file.
Currently, when someone clicks an item in the list, the following module is loaded:
<DisplayItem file_name={this.state.selected_file} />
Then in my DisplayItem I have the following:
const item_data = require('./' + this.props.file_name);
However, I get the error:
Invalid call at line 52: require(file)
Apparently, I am unable to do imports or requires when the filename is dynamic. The only solutions I have seen is to manually require all of them first of all.
I find this solution a bit challenging because then I end up with redundant data. Any time I update the menu.json file then I have to remember to make the exact same update to the module requiring all the json files.
Is there a more efficient way to do this that eliminates the redundancy issue?
As I know You can't require a file in react native from a dynamic value, because it will make the compiler doesn't know which file to be included when building the app.
As written in React-Native's Image documentation
In order for this to work, the image name in require has to be known
statically.
For example
// GOOD
<Image source={require('./my-icon.png')} />;
// BAD
var icon = this.props.active ? 'my-icon-active' : 'my-icon-inactive';
<Image source={require('./' + icon + '.png')} />;
// GOOD
var icon = this.props.active ? require('./my-icon-active.png') : require('./my-icon-inactive.png');
<Image source={icon} />;

Is it possible to use two objects: Force and Multiple in Cypress Test?

I am using cypress test to check all the buttons in the page whether they can be clicked or not.
I have used this line of code:
cy.get('button').click({ force: true }).should('have.attr', 'href')
and gives error
CypressError: cy.click() can only be called on a single element. Your
subject contained 5 elements. Pass { multiple: true } if you want to
serially click each element.
After that changed code with:
cy.get('button').click({ multiple: true }).should('have.attr', 'href')
and got another error
CypressError: Timed out retrying: cy.click() failed because this
element is not visible:
...
This element
''
is not visible because it has CSS property: 'display: none'
Fix this problem, or use {force: true} to disable error checking.
https://on.cypress.io/element-cannot-be-interacted-with
Is there any way to use both object to solve the problem?
This should work (I don't have a situation to test it when both needed, but it doesn't result in an error):
cy.get('button')
.click({ multiple: true, force: true })
.should('have.attr', 'href')
Here is a generic way of doing it -
cy.get('button').each(($btn) => {
if ($btn.hasClass('disabled')) {
// logic to deal with disabled button
}
else {
// click button or do whatever
cy.wrap($btn).should('have.attr', 'href').click();
}
})
each will help you loop through every button, whatever may be the count. This allows you to not worry about force clicking an element (button in this case).

How to verify error messages using Geb

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()