I'm writing a test that checks the input of 2 fields, one is type text and the other is type number.
I can grab the text input without issue and test it:
textInput = getAllByPlaceholderText('name');
userEvent.type(textInput[0], 'username');
This works perfectly when I check the test with screen.debug();
But the number input is very different.
numInput = getAllByRole('spinbutton');
userEvent.type(numInput[0], '1');
This doesnt change the value when checking the debugger.
I've been searching online for an answer but failed to find anything, could someone help?
I'm guessing the userEvent needs changing but since any actual users can simply type into this box should .type still work?
I have no idea why this is the case but
userEvent.type(textInput[0], 'username');
userEvent.type(numInput[0], '1');
The above only shows textInput as having a value.
userEvent.type(numInput[0], '1');
userEvent.type(textInput[0], 'username');
This shows them both as having a value, no idea why but hey, its working.
Related
I am trying to write automated screenshotter using puppeteer in node.js which will navigate to particular url.url have one faeture for search box which will give the information for desired query.If we get desired output screenshot is taken and saved to "success" folder but we didnt get any result (like no result found), i want screenshot in "failure" folder. Is It possible to record the response and segregate the screenshots.
You can check html value and return value with page.evaulate() then you can use switch case according to incoming value and use page.screenshot() function.
Here is your question broken down to bits,
You are trying to,
write automated screenshotter using puppeteer in node.js
which will navigate to particular url.
url have one feature for search box.
which will give the information for desired query.
If we get desired output
screenshot is taken and saved to "success" folder
but we didnt get any result (like no result found),
i want screenshot in "failure" folder.
Is It possible to record the response and segregate the screenshots?
The answer is, Yes.
For example, it can be a simple google/yahoo/duckduckgo results scraper . Save screenshot depending on the result count.
You can use .goto to go to the page, .$$ to check the results, .screenshot to take screenshot depending on the results.
Here is an example code to check if there is any result or not,
let results = !!await page.$("div > div > h3 > a");
// returns if there is any result in google search
let path;
if (results) {
path = "success/mysuccessimage.png";
} else {
path = "failed/myfailimage.png";
}
await page.screenshot({ path });
Since you did not share any code, no one will be able to help you. But I guess I answered your question. Now, you can implement it in a thousand ways, peace.
This is probably a stupid one but I have tried all the things I can think of. I am currently getting the below error on my client side script when I try and execute it.
Error: ReferenceError acvt_serialNumber_saveRecord is not defined
On the Script record in Netsuite I have set the saveRecord function as follows:
acvt_serialNumber_saveRecord
The code in the file is:
function acvt_serialNumber_saveRecord(){
/**do stuff */
}
I have reuploaded to code to make sure the right version was in NetSuite. I have added one character to both the script fn name and the fn name on the Script record (as a shot in the dark). I have seen in the Javascript console at runtime that the correct code is in there and I can see the exact function name (I did a ctrl+f for the "undefined" function in the code in the console to make sure spelling was all the same).
NOTHING has worked. I had this code working earlier, but the changes I made were not to this function at all.
Any help is appreciated
Another thing to check is the code that you recently changed. In particular, check for a hanging comma. IE:
var someObj = {
someProp:'somevalue',
};
The comma at the end of 'somevalue' will cause the script to fail, throwing 'undefined' errors.
Have you tried deleting the Script record in NetSuite and re-creating it?
Do you have any library included for that Client Script in netsuite ?
Provide a screen shot of your Netsuite script page
I encounter similar problem like this before, but it was because i called a function which is inside a library file
Thanks
In the below example, infoScroller is a UIWebView and println(HTMLDescription) prints a lovely string of HTML. However, the attempt to loadHTMLString gets the runtime error: fatal error: Can't unwrap Optional.None
if let HTMLDescription = self.myData?.content? {
println(HTMLDescription)
infoScroller.loadHTMLString(HTMLDescription, baseURL: nil)
}
I've tried every combination of ! and ? in both the assignment and use of the string but I get this same error every time, though the variable never fails to print out perfectly to the console.
There is another value that I set using the same method and it works fine. Both are strings, but the other one is more simple in that HTMLDescription is multiline and the working one is not.
Edit: The discussion in the comments prompted me to check the infoScroller and it's description as printed in the console is: (#sil_weak UIWebView!) infoScroller =
I'm thinking that's the issue, but I'm not sure what it means or how to fix it.
Edit 2: This has to be the issue. println(infoScroller.description) yields the exact same error.
Got it! This question put me on the path. I was trying to load the content before the view was fully loaded. Moved loadHTMLString() into viewDidLoad(). Stupid simple.
I'm trying to set up a coded UI test to allow me to check for an error message on a login. The test runs, but I'm struggling to get the assert to work.
The response that comes back is nested as follows:-
<div class='ui-errors'>
<ul>
<li>Your password is invalid</li>
</ul>
</div>
What do I need to set up to check the first li in the div of that class in an assert?
Coded UI can capture DIV. In the following code I've created a custom DIV object from your provided example. AdrianHHH's answer will definitely get you information you need to insert in to my example.
var error = new HtmlDiv(new Parent(RootParentWindow));
error.SearchProperties.Add("Class", "ui-errors");
var errors = error.FindMatchingControls();
foreach (var item in errors)
{
Assert.IsTrue(item.GetProperty("InnerText").ToString().Contains("Your password is invalid"));
}
Coded UI does not really look at DIVs or ULs etc. Coded UI looks at what is drawn on the display. I suggest you use the Coded UI cross-hair tool to examine the error message then add an assertion to check for the message. You might also examine the same area of the screen for a test which passes to see how they differ.
If you are hand coding your test rather than letting Coded UI generate the code for you, I recommend creating a sandbox project and recording the assertion into that. Then copy the useful ideas from the generated code into your own test code.
If you can get a sample of the page where the assertion is needed I could create it for you, otherwise do what AdrianHHH said.
In case you don't know when you use the assertion tool, all the options you get are different ways to assert that particular control, eg you could assert if it exists or if the inner text is equal etc.
yonitdm answer will solve your problem, but as per your words, "first li in the div of that class" try below.
// Find Error Div
var errorDiv = new HtmlDiv(new Parent(RootParentWindow));
errorDiv.SearchProperties.Add("Class", "ui-errors");
errorDiv.Find();
// Get UL - First item in div
var errorUL = errorDiv.GetChildren().First(); // or GetChildren()[0]
// Get all LIs and take first item
var firstLI = errorDiv.GetChildren().First(); // or GetChildren()[0]
Assert.IsTrue(firstLI.GetProperty("InnerText").ToString().Contains("Your password is invalid"));
I'm trying to write automated tests for Hashify Editor. Here are the sorts of assertions I'd like to make:
Assert that a textarea matches a particular selector.
Assert that the textarea is currently empty.
Type "_" into the textarea. Assert that it now contains __, and that the caret is positioned between the two underscores.
Type "hello" into the textarea. Assert that it now contains _hello_, and that the caret is positioned before the second underscore.
Type "_" into the textarea. Assert that it still contains _hello_, and that the caret is now positioned after the second underscore.
I've spent the day playing with Soda and Zombie.js, trying to get this work in either. I've managed to get close with Soda:
soda = require 'soda'
browser = soda.createClient ...
browser
.chain
.session()
.open('/')
.typeKeys('editor', '_')
.assertValue('editor', '__')
This assertion success, but the following doesn't:
.typeKeys('editor', 'hello')
.assertValue('editor', '_hello_')
# ERROR: Actual value '__' did not match '_hello_'
Using .type fails in a different manner:
.type('editor', 'hello')
.assertValue('editor', '_hello_')
# ERROR: Actual value 'hello' did not match '_hello_'
The suggestion on #275 of assaf/zombie got my hopes up, but I wasn't able to trigger the textarea's keypress handler using this approach.
Perhaps I'm going about this in the wrong way. Has anyone had success testing keypress handlers using Node? What's the best tool for the job?