Flutter Testing: Retrieving values from text field - authentication

I am currently testing my login page in flutter and I want to make sure that the values I am entering are the ones being passed when I click log-in (username and password). I want to do more than just validate if the inputs are in a certain format. I would like to see if I wrote "Tom123" it returns "Tom123". What is the best way to go about testing this?

I believe there is a documentation specific for this kind of test:
enterText method
Give the text input widget specified by finder the focus and replace
its content with text, as if it had been provided by the onscreen
keyboard.

Related

Is there a way to send or trigger keystrokes in Cypress on a webpage?

what I am trying to do is that when I navigate to a certain page there I need to press certain key from the keyboard i.e. alphabets to perform an action on the webpage.
The scenario is:
1- Navigate to webpage
2- Press a specific alphabet from the keyboard
3- Page performs an action when this alphabet is pressed from the keyboard
Currently, I am not sure how can I achieve this with Cypress normally we can type in the input box etc but I just want to simulate the keypress on the webpage. Is there a way to do this with the help of trigger function? if so then how to do it?
Yes you can send the key strokes to in cypress
cy.get('input').type('{shift}{alt}Q')
cy.get('input').type('{enter}')
Maybe this helps:
https://sqa.stackexchange.com/questions/46912/how-to-simulate-a-simple-keypress-in-cypress
Also, check out the documentation for Trigger in cypress. Check out recipes too. maybe you'll find something helpful.
Yes, here's the official documentation by Cypress. Just use the key modifiers in the .type() method:
.type('{meta}{command}{cmd}')

Telegram Bot api custom keyboard additional data values

Is there any way to pass additional data values from custom keyboard layout buttons?
I need to pass a value like ID that they are hidden from user:
{"Button1",{"id":1}} ...
You cannot do it with custom keyboards, but it is possible with callback_data param of InlineKeyboard
When user will press inline button with callback_data specified message received by bot will be type of CallbackQuery with data param containing your data from the button.
That's not currently possible. It would be a great addition to the API, though, in order to separate the text you see from the value you send back to the bot.

What is the proper way to test mandatory field in selenium

I am testing my web application using Selenium. All the form validation in the web application is done by HTML5 and some JS(for safari browser). I want to know what is the proper way to test the form validation.
Currently I am using one approach, i.e Before I filled up a mandatory field I clicked on the submit button. If the page is not refreshed then I assume the form validation working correctly. But I think there should be a better approach to do it. I am unable to find any proper solution. Any suggestion will be highly appreciated.
I also go through this link. But it is not working for me because it is not enough to have required attribute (eg required attribute does not work in older Safari browser).
Rather than checking if the page is refreshed or not, you should instead expect that it is not and that a certain error message or field highlighting or something is applied to the current page. When in an error state, the input fields probably get given an extra class, or an error div/span might be added to the DOM, try checking for that sort of thing

Filling in hidden inputs with Behat

I am writing Behat tests and I need to change the value of a hidden input field
<input type="hidden" id="input_id" ..... />
I need to change the value of this input field, but I keep getting
Form field with id|name|label|value "input_id" not found
I have been using the step
$steps->And('I fill in "1" for "input_id"', $world);
Is there something special which needs to be done to modify hidden input fields?
Despite the fact that user can't fill hidden fields, there are some situations when this is desirable to be able to fill hidden field for testing (as usually rules have exceptions). You can use next step in your feature context class to fill hidden field by name:
/**
* #Given /^I fill hidden field "([^"]*)" with "([^"]*)"$/
*/
public function iFillHiddenFieldWith($field, $value)
{
$this->getSession()->getPage()->find('css',
'input[name="'.$field.'"]')->setValue($value);
}
Rev is right. If real user can can change input fields via javascript by clicking a button or link. try doing that. Fields that are not visible to user are also not visible to Mink also.
Or else what you can do is Call $session->executeScript($javascript) from your context with $javascript like
$javascript = "document.getElementById('input_id').value='abc'";
$this->getSession()->executeScript($javascript);
and check if that works
It's intended by design. Mink is user+browser emulator. It emulates everything, that real user can do in real browser. And user surely can't fill hidden fields on the page - he just don't see them.
Mink is not crawler, it's a browser emulator. The whole idea of Mink is to describe real user interactions through simple and clean API. If there's something, that user can't do through real browser - you can't do it with Mink.
(source: http://groups.google.com/group/behat/browse_thread/thread/f06d423c27754c4d)

iPhone Web Application

I had a quick question regarding UIWebView. Is there anyway to programmatically navigate the UIWebView? Essentially, I prompt the user for certain information, such as (Current Location, Time). Using this information, I would like to fill out and complete a form on a webpage, and display the resulting UIWebView to the user. Is this possible?
You could use JavaScript to control the UIWebView using the stringByEvaluatingJavaScriptFromString method. For example you should be able to insert text into an input and submit a form:
NSString* script = #"document.getElementById('Name').value = 'Hello'; document.getElementsByTagName('form')[0].submit();";
[self.web stringByEvaluatingJavaScriptFromString:script];
You'd have to customize the JavaScript to do whatever you want. For example, you could inject values that you had collected into the script, then run the JavaScript.
You could hide the UIWebView until the new page had loaded, then show it to the user.
Come to think of it, it'd be nice if there were a Selenium type wrapper around the web view, but I don't know of anything like that right now.