Asserting text in nightwatchjs - assert

So in my nightwatchjs test I would like to check that the correct text is displayed for a couple of elements.
The first element (for example) is highlighted below in yellow;
I thought this would be simple to assert, but I just can't seem to get the text!
I've tried;
browser.expect.element('.why-buy-from-dealer h4').text.to.contain('Why buy from MCN Test Dealer');
and;
browser.getText("css selector", ".why-buy-from-dealer h4", function(result) {
console.log("getText result", result.value);
});
and;
browser.assert.containsText(".why-buy-from-dealer h4", "Why buy from MCN Test Dealer");
But each time I'm getting a result of "" (or null).
This is also the same for the element just under this one .why-buy-from-dealer p
Any help would be greatly appreciated. Thanks.

Did you wait for the element to be visible?

Yeah, I’ve now realised my mistake. I was testing this using my headless setup, and as such the elements weren’t being rendered in the DOM. Testing this launching an actual browser rectified the issue.
Many thanks for taking the time to reply to my post.

Related

How to fix Renpy choice code logic error? All roads lead to route 1

How do I make it so the first route text only activate if mc chooses "yes" for the 1st choice and "no" for the 2nd one? Pls help I wrote 500+ lines of code for the first route before noticing this.
So I just published a demo of my visual novel on itch.io. The full game is going to have 7 routes (6 n 1 hidden). At the start there are 2 questions with 3 and 2 choices each, that are supposed to branch off into 6 routes. Currently only the first route is finished, and any other combination is supposed to stop the game after one reply. However, this doesn't happen, instead after showing one reply and skipping some choice it just returns on track for route 1.
I made the bug seem like a demo feature by saying "this demo only contains one route, you will be redirected to this route." But in reality, it redirects to that route whether I want it or not. How do I make it stop doing that?
pretending bug is a feature
where stuff goes awry
TL:DR: As stated above, the first route should only activate if mc chooses "yes" for the 1st choice and "no" for the 2nd one instead of all the time.

Use the sheet number to check the active sheet

Before some code runs, I want to check it is the correct sheet.
I can use the sheet name, but my concern is that if someone changes the sheet name, the code won't run. The sheet index also seems to change if the sheet is moved.
Therefore I want to use something that doesn't change.
I believe the sheet number and sheet ID never change.
So I was hoping to use one of them, but I can't see a way of doing that.
What I want in non-coding language is:
If active sheet number = 4 then run the code or
If active sheet ID = 0123456789 then run the code.
Thanks to JPV's link, I have an answer and learned a few things.
You can't use the sheet number to check if the correct sheet is active.
You can use the getSheetId(), but the return you get is not useable.
To make it useable, you need to add getSheetId().toString().
To do the if statement, I needed two equal signs.
if (SpreadsheetApp.getActiveSheet().getSheetId().toString() == 0123456789) {do this when true}
I've been trying to solve this for days, so I should have come here and asked for help earlier.
The main thing I didn't know was the "toString()" part. It always seems so easy and obvious once I know.
Thank you, JPV.
Thanks to JPV's link, I have an answer and learned a few things.
You can't use the sheet number to check if the correct sheet is active.
You can use the getSheetId(), but the return you get is not useable.
To make it useable, you need to add getSheetId().toString().
To do the if statement, I needed two equal signs.
if (SpreadsheetApp.getActiveSheet().getSheetId().toString() == 0123456789) {do this when true}
I've been trying to solve this for days, so I should have come here and asked for help earlier.
The main thing I didn't know was the "toString()" part. It always seems so easy and obvious once I know.
Thank you, JPV.

On the 4Clojure website, how do you see your previous problems, so you can return to one of them?

I'm doing problems at 4Clojure. Some how, when I finished a problem (around #22), a link appeared that jumped me to problem #35. I want to do the problems that were skipped. But when I'm logged in to 4Clojure, the website only shows me problems after the last one I completed, which is #34.
Is there way to see all the problems (completed and uncompleted) at 4Clojure, so I can do the skipped ones?
The headers on the problem list page are all clickable to change sort order. The default sort order is something like "sort first on whether you've solved it, and then on how many other people have solved it", so problems you've solved drift to the bottom (which is on page 2). You can click a heading to sort differently: for example, click on the Solved heading to see the problems you've already solved first.
Or, of course, you can just edit the URL, since the URLs are very predictable: http://www.4clojure.com/problem/22 will be problem #22.
Change the number in the URL:
http://www.4clojure.com/problem/[problem]
Your completed problems appear at the very end of the problem list.
There seems to be a list of all the problems:
Problem List
However they are not numbered.

MVC3 unobtrusive validation with regex, always fails first time, then works

I'm trying to use the DataAnnotations RegularExpression attribute on a property of an item in a collection - A Field object has a collection for Formatter objects that in turn have a collection of Attributes with a Value property.
Inside my attribute view model class, I have:
[RegularExpression(#"^\d+$", ErrorMessage = "That didn't do what you hoped it would do")]
public string Value { get; set; }
I have this in my view:
#Html.TextBoxFor( x => x.Formatters[fmt].Attributes[att].Value )
and it produces this markup:
<input type="text" value=" " name="Formatters[1].Attributes[0].Value" data-val-regex-pattern="^\d+$" data-val-regex="That didn't do what you hoped it would do" data-val="true" >
All of that seems right, but the validation always fails the first time. If I enter 23 into the textbox and tab out, it fires the validation event and tells me things didn't go like I'd hoped they would. If I go back to the field and enter the exact same value, it works. If I enter letters, it still fails as it should.
Anyone have any idea what I might be doing wrong or what I can do to coerce the validation into behaving the first time around? It seems to be related to the collections somehow because if I put the same validation attribute on a top level property, it works as it should.
Thanks!
This issue appears to be isolated to my laptop at work. I pulled down the code to a couple of other computers at home last night and everything works as expected.
I'm still not sure what's going on, but I don't think this is something the community can help resolve - unless someone wants to loan me a hammer.
Thanks for reading and thanks to Darin for trying to dig deeper.

Hash anchor tag causing errors in URL

On very rate occasions, my error log is showing the following error:
"You specified a Fuseaction of registrationaction#close which is not defined in Circuit public."
The full link is:"http://myUrl/index.cfm?do=public.registrationAction#close"
As you can see, the has merely points to an anchor (close) on the page.
This code is working 99% of the time, but on the odd occasion, Coldfusion / Fusebox throws this error out.
Why is this happening?
Could it be related to the device accessing my page somehow? Like a cell phone or Apple product that for some reason does handle hashes the way I am expecting it to?
Could it be javascript / JQuery being disabled?
Any guidance would be appreciated
Thanks
I used to see stuff like that. Older versions of Internet Explorer were not handling the hashtag properly when there were URL parameters. The best solution I could come up with was kludgey at best, but basically it forced the anchor tag to separate from the URL parameter.
http://myUrl/index.cfm?do=public.registrationAction&#close
I'm not sure there is a simple answer to this. We get odd exceptions all the time on our site for all sorts of reasons. Sometimes it's people not using the site the way you expect and sometimes it stuff like you mention such as user-agent edge cases etc.
Basically you need to start to gather evidence and see what comes up that's unusual with these requests.
So to start: do you catch exceptions in you application? If so dumping all scopes (CGI/CLIENT/FORM/URL/SESSION) in an email along with the full exception and emailing them to a custom emails address (such as errors#yourdomain.com) will give you a reference you can square up to your error times and this might give you a hint as to the real issue.
Hope that helps some!