I am writing ember acceptance tests, and when redirecting as in
visit('/get-started');
it actually visits the page in the browser, redirecting away from /tests.
Any thoughts on what could be causing this?
I am on Ember 2.11.0
I think this behaviour is by design. When you visit('/get-started'); in your acceptance test, it should navigate to the given path in the browser, and perform whatever acceptance criteria you are trying to test.
I'm not sure what your acceptance criteria is for the /get-started page, but if you wanted to simply test that the navigation was successful, your test might look like:
test('navigate to /get-started', function(assert) {
visit('/get-started');
andThen(function() {
assert.equal(currentPath(), 'get-started');
});
});
I'm not sure how acceptance tests worked in older versions, but for the current version(2.11.0), I think it is working as intended.
Related
TestCafe devs: Thanks for creating a great, easy to use product!
I'm using testcafe to do full end-to-end tests on my electron app, which is sending XHRs with most endpoint URLs having the file:// scheme and some others an API that we control.
I fixed the CORS issues (testcafe proxy was responding with the 222 code) with the file:// URLs by starting up the Http-server npm package with --cors turned on.
My current problem is that when my app sends the XHR to the API, nothing I seem to do resolves the problem. I'm not looking to mock the API requests. When not running my app inside testcafe instances, both file:// and API requests have no issues.
Is there a (straightforward) way to solve this? (Also, is there a similar solution for the file:// requests without having to create a webserver?) I'm assuming this issue is common, and I have looked thru the Github issues for both testcafe and testcafe-hammerhead as well as the Recipes page. I've also tried to create a request hook, but I'm still getting the 222 response code.
Here is my custom hook:
class MyHook extends RequestHook {
constructor(requestFilterRules) {
super(requestFilterRules, {includeHeaders: true, includeBody: true});
}
onRequest(event) {
event.requestOptions.headers['Origin'] = 'file://';
console.log(event);
}
}
I'm assuming that all I had to do was change the Origin: header to something that my API accepts, per the above code. (I'm guessing that the presence/absence of the includeHeaders/include body properties or the response method in the above code do not have an effect here, but I'm not sure.)
Thank you!
hi i'm new to ava testing. I am able to test for pages that are shown to non logged in users. Now i would like to test for logged in users which means the pages will change accordingly. How do i test for such a scenario? My best guess is to use Phantomjs or nightmarejs with ava.
i use cucumber ruby for automation testing at browser. i need print cookies the browser
how to get cookies in browser in capyabara
1. inspect element at browser
2. application
3. print the cookies
how to print cookies browser in cucumber capyabara
i have try
puts Capybara.current_session.driver
but print like this
#<Capybara::Selenium::Driver:0x007fcbf52e2250>
Since feature tests (which is what Capybara was/is designed for) really shouldn't be dealing with cookies (test user visible things, not implementation details) there is no Capybara cookie API. This means any access is going to be driver dependent. In your case you appear to be using selenium so it would be
page.driver.browser.manage.all_cookies
i try this can be solve
Capybara.current_session.driver.browser.manage.cookie_named("browser_id")[:value]
Using PHP Codeception and WebDriver PHP wrapper (Facebook), is it in general possible to get the environment variables of the actual page request, made by PhantomJS or a real browser used?
Maybe it is just my misunderstanding of the technology behind acceptance tests, but given the fact that a testing framework like Codeception is requesting a page using PhantomJS or a real browser like Chrome or Firefox, I would expect to have access to e.g. the $_SERVER global variable. Unfortunately I can not find any methods providing this in WebDriver Codeception module or Facebook PHP WebDriver wrapper.
Specifically, I have a page which is supposed to use SSL only, so a 301 redirection is expected to happen when visiting the page.
I need to have an acceptance test case in Codeception to check just that and checking the $_SERVER['HTTPS'] global variable should do it.
First I tried to match the URL against 'https://' but the WebDriver wrapper method _getCurrentUrl() delivers only the URI part without protocol and host.
Then I tried to get the $_SERVER variable inside custom Helper action, but the one accessed directly looks like it comes from the CLI environment, not a browser request.
No, you can't access $_SERVER in acceptance tests, because $_SERVER is in server-side and all you have is a client.
If you want to check a complete url, you can use getCurrentURL method of webdriver instance, it can be accessed in the same way as _getCurrentUri method in your helper.
public function checkUrl()
{
$url = $this->getModule('WebDriver')->webDriver->getCurrentURL();
//do your checks here
}
If already used WebDriver module:
$currentUrl = $I->executeJS('return jQuery(location).attr("href");');
I have a login form that send the login info with Ajax.
If the login is wrong, I send a .js that shows some alert and shakes the form.
If the login is successfull, I simply want to redirect the full page.
The Rails controller expect always a .js call, and actually in both cases I send a .js reply, because the redirect in rails will go into some .js reply that the browser expect.
login wrong:
$("#login").effect("shake", { times:2 , distance:10},20);
login successfull:
window.location.replace("<%=root_url(:only_path => false)%>enterprises/");
The question is if this is a good approach (personally I don't like it but it works) or are better ways to handle this.
thanks,
I think it is a good solution. Mayby I would fix the url in case of a successful to depend on a helper, instead of a hardcoded path, but it is a minor thing.
Maybe it can be good to have an additional .html view on both actions in case of the user disabled the javascript in the browser.