Codeception ->see("String") fails but ->seeInSource("String") succeeds - codeception

Something is wrong with the AcceptanceTester->see() method for me. It can't see things that are plainly there in the source, as shown by the AcceptanceTester->seeInSource() method.
Here's my test, which runs in PHPBrowser within the WP-Browser implementation of Codeception:
public function testAfricaIsVisible(AcceptanceTester $I) {
$I->amOnPage('/');
$I->seeResponseCodeIs(200);
$I->seeInSource('Africa');
$I->see('Africa');
}
Here's the result I get:
As you can see, ->SeeInSource("Africa") works, but ->see("Africa") fails.
I understand that ->SeeInSource() sometimes "sees" things that ->see() doesn't, but in this case, the word "Africa" is link text that should be clearly visible with or without strip_tags() applied.
In this case, when I open up the Html link the word "Africa" is clearly visible:
Anyone have any idea why Codeception doesn't ->see() this text?

I figured it out. For anyone with a similar problem, the underlying issue was malformed HTML that was glossed over by Chrome/Firefox but screwed up the site as seen by Phpbrowser. I bet if I was using the WebDriver module instead, it would work.
The solution: Use an HTML validation tool and fix the reported syntax errors.
In this case it was a title tag with a single-quote in it, e.g. title='doesn't'

Related

This JSFiddle is not loading p5.js correctly

This code I have written in my JSFiddle works well in my computer, and it creates a button and loads a sketch each time I press the button. I "loaded" p5.js, p5.dom.js via CDNJS cause p5.js is not available in the javascript frameworks and extensions options. But the behaviour is not being reproduced correctly. What is wrong with it?
Link: https://jsfiddle.net/truxx/uf7y9meq/5/
I tried:
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.11/addons/p5.dom.js"></script>
You've got a few things going on here. First of all you should really fix your HTML. You've got mismatched and illegal tags all over the place. Please try to fix all of these problems, and properly format your HTML while you're at it.
It also seems pretty strange that you're trying to mix instance and global mode. Why do you have a setup() and mousePressed() function outside of the sketch function, and another setup() function inside the sketch function? What do you expect that to do?
To fix those problems, you need to choose either instance or global mode. This might require you to rewrite some of your code, but your goal should be to make everything consistent instead of using two different modes in one sketch.

Javascript code not recognised in Intellij IDEA 12 in scala template for Play 2

I just installed the recently released Intellij IDEA 12, which is GREAT for Play Framework 2.
However, I'm having the following issue: in an HTML Scala template, any JavaScript code enclosed in a <script> tag within the body of the template is not recognised as JavaScript by IDEA, thus not offering code completion and incorrectly showing errors where they aren't. I suspect it is interpreting the code as Scala code, ergo offering incorrect code completion and making it quite painful to write JS in a template.
This issue was not present in IDEA 11.
Any ideas?
Update
I have the JavaScript Support plugin enabled. Simple code completion works fine. However, if I type function (){} to code an anonymous function and hit Enter with the caret between the curly brackets, IDEA does the following:
If I manually fix the incorrectly added }, and write code for the anonymous function, it offers correct variable suggestion for the console.log although it is stil showing errors:
I can't confirm that, I can see that both, Scala and JavaScript completion works properly.
Go to Settings > Plugins and make sure that you have JavaScript Support enabled. After that close and reopen all your views to let the Idea analize syntax once again.
It appears that your function statement is invalid because you did not name your function. The details of what is going on here are answered in this post. I'm not sure of the details of your particular needs, but you might try this syntax instead:
<script>
(function() {
})();
</script>

Mysterious FireBug Error repeats with ExtJS

When debugging ExtJS 4 (tried both versions 4.1.0 and 4.1.1), FireBug repeatedly shows the following error: An invalid or illegal string was specified
http://docs.sencha.com/ext-js/4-1/extjs/ext-all.js
Line 18. It does not break on the error, though that option is specified. Additionally, neither my code or ext-debug.js and it's loader seem to actually call ext-all.js.
This error gets logged to Firebug's console about once per minute, which is annoying. What bothers me is that I cannot get the error to go away. Is this a FireBug bug? An ExtJS bug? Aliens? How can I debug the debugger?
I had the same problem before and I've solved it by removing a special character at the end of my JS file! (app.js I think)
It was weird, but the problem came from hidden special characters like: Zero-width non-joiner or Right-to-left mark.
Open another JS file but do not copy/paste your code there. Just write it again and check whether the problem exists or not.
And don't forget to check your data if you have some. As this article explains about the problem: http://www.ashorlivs.fr/javascript-jquery/article/an-invalid-or-illegal-string-was
For general debugging see this link http://www.sencha.com/learn/debugging-ext-js-applications/
You can also use ext-all-dev.js while in development mode.
There is another excellent tool on top of firebug, at this link http://www.illuminations-for-developers.com/
PS: I still didn't figured out how to post a comment. I guess it comes when I have more points/reputation. Hence adding it as an answer. thanks.

Selenium: intermittent "element not found" issues

Every now and then my selenium tests randomly fail with an "element X not found" error message. I do a simple select by ID, eg.
click('sideBar_queryButton')
When I use the dom inspector, the element is there, so I wonder why selenium doesn't find it sometimes. When I run the same test again, it works or it breaks again, there seems to be no reliable way of reproducing it. Even tests which are there for ages seem to randomly break and then magically work again. Inserting a few sleep statements sometimes helps but not reliably. So I wonder if I'm using it incorrectly. Has anyone else had these problems with selenium and if so, how did you fix them?
Edit: I found it to be much more reliable to put some test markers in my pages and wait for them to appear. If you use asynchronous operations which might create race conditions in your tests, inserting a test marker into your html after you finish the operation worked pretty well for me. E.g.
$('<div>').addClass("testMarker").append("OpXYZFinished").appendTo($('#content'));
That way, you can do a simple "waitForTextPresent" to see if things worked out and its much more reliable than guessing the browser's loading state. The testmarker class needs to be formatted in a way that it is not visible to the user (e.g. font color == background color).
Thanks for all your comments. After some deeper digging on the net and
in our tests I finally found combining these statements instead of a
simple waitForPageToLoad to be the cure for our issues:
waitForPageToLoad('')
// wait until all ajax activity has ceased. That check's jQuery's $.active
waitForCondition('selenium.browserbot.getUserWindow().$.active == 0', 5000)
// wait a second for all JS to properly initialize
pause(1000)
There is still a pause in there which is somewhat ugly, but it does
the trick.

Dojo - Some of my form.dijit's seem to be dead/inactive on one page

I was started to work on my first sample of the dijit.Tree control.
When it didn't work, I added a couple of dijit.form.Textbox'es to the screen, and they didn't work either, even though I have them working fine on a similar form.
Interesting enough, when I killed FireFox and restarted it, I was got a clear message in FireBug console on what was wrong with my tree control, and got it fixed.
But now I'm rather puzzled while the simple dijits like NumberTextBox that I added are not working.
My Samples:
1) http://3wcloud-com-provisioning-qa.appspot.com/testDijitDate - this works great
(except the initial date value not showing - I have a separate question open on that)
2) http://3wcloud-com-provisioning-qa.appspot.com/testDijitTree
I've done several "diff"s on the two files, and I kind find the difference that would cause one to work and one not to work.
Thanks,
Neal
You should put your dojo.require statements immediately in a script block, not wrapped in the onload callback. Also, your input tags should be HTML style without the XHTML style slash (you didn't declare XHTML in your document) though I doubt that's the problem. See if either of those things help.