backstopjs missmatch errors issue - backstop.js

I am new to backstopjs, I was able to download it globally. My project directory structure looks like the following. I set up instance of backstopjs in my tests/backstopjs directory with backstop init :
The page I want to reference is index.html in my app directory:
My scenarios in the backstop.js file are the following:
"scenarios": [
{
"label": "My index test",
"url": "~/app/index.html",
"referenceUrl": "",
"readyEvent": "",
"readySelector": "",
"delay": 0,
"hideSelectors": [],
"removeSelectors": [],
"hoverSelector": "",
"clickSelector": "",
"postInteractionWait": "",
"selectors": [
".list-content"
],
"selectorExpansion": true,
"misMatchThreshold" : 0.1,
"requireSameDimensions": true
}
],
I am trying to taget the list-content class on my index.html page.
The error I am getting is:
report | *** Mismatch errors found ***
COMMAND | Command `report` ended with an error after [0.089s]
COMMAND | Command `test` ended with an error after [32.08s]
And the report page result:
Is my url path completely wrong, or is it something else I have missed?

Sorry, my url path was wrong, I tried it out on a simpler project setup.
But from the screen dumps above, can someone suggest the proper relative path for my url setting from my tests/backstopjs folder where the backstop.json exits to my app where the index.html file exists?

Related

Issues with the aurelia-tabbed project

I'm trying to include aurelia-tabbed in my aurelia project (of which I think I have the latest version, but I can't find a version number anywhere). I have a problem however, because I'm using a bundle of my app and vendor js, and I don't know how to include the package.
I've tried adding this in my aurelia.json in build > bundles > (vendor) > dependencies:
{
"name": "aurelia-tabbed",
"path": "../node_modules/aurelia-tabbed/dist/amd",
"main": "index",
"resources": ["assets/tabs.css"]
},
However, while this compiles, I cannot run the webpage. It gives me errors in the console (even before I add any of the tabbed tags):
DEBUG [aurelia] Configured plugin aurelia-tabbed.
vendor-bundle.js:5700 GET http://localhost:9001/analysis/test-page/node_modules/aurelia-tabbed/dist/amd/tab-headers.js
vendor-bundle.js:5700 GET http://localhost:9001/analysis/test-page/node_modules/aurelia-tabbed/dist/amd/tabs-wrapper.js
vendor-bundle.js:5700 GET http://localhost:9001/analysis/test-page/node_modules/aurelia-tabbed/dist/amd/tab-content.js
vendor-bundle.js:1395 Unhandled rejection Error: Script error for "aurelia-tabbed/tab-headers"
http://requirejs.org/docs/errors.html#scripterror
at makeError (http://localhost:9001/scripts/vendor-bundle.js:3907:17)
at HTMLScriptElement.onScriptError (http://localhost:9001/scripts/vendor-bundle.js:5477:36)
The three calls all result in 404's (which is normal, because the node_modules path is located at the root).
However: why are the three calls even made? Aren't the files supposed to be bundled?
In your aurelia.json file, you need to list all resources of the plugin. Try the following:
{
"name": "aurelia-tabbed",
"path": "../node_modules/aurelia-tabbed/dist/amd",
"main": "index",
"resources": [
"tab-content.html",
"tab-headers.html",
"tabs-wrapper.html",
"assets/tabs.css"
]
},

can't seem to get static route with kraken.js

I'm trying to upgrade an existing express site to use kraken.js
I've got my dynamic pages loading ok (so far), but I can't seem to serve static files.
Looking at the example, pages, it seems simple enough that I just have to add
"middleware": {
"static": {
"arguments": [ "path: ./client" ]
}
}
In my config.json file. The file I'm trying to serve is ./client/build/js/bundle.js, and I can confirm that the file exists in the folder. It is NOT in a ./public folder.
What do I need to do to get kraken (or kraken.js static-serve) to find my static files?
I've placed the file in a ./public/client/build/js/bundle.js and kraken has no problem finding the file in that location.
I think you might be missing the "module" member of the middleware object. My current Kraken-generated static middleware config object looks like this:
"static": {
"module": {
"arguments": [ "path:./.build" ]
}
}
OK, I found out how to make it work. Notice how in your config that "public" isn't in there? That meant it was being pre-pended or configured somewhere else. That somewhere else is in /node-modules/kraken-js/config/config.json. I amended it to look like this:
"static": {
"enabled": true,
"priority": 40,
"module": {
"name": "serve-static",
"arguments": [ "path:./public", "path:./client" ]
}
},
Then in your regular /config/config.json I edited the static object to look like this:
"static": {
"module": {
"arguments": [ "path:./.build", "path:./build" ]
}
},
Notice that in the second argument there is not a "." before build.
Finally, I used script tags that looked like this in the master layout:
<script src="/js/test.js"></script>
So, from your root project directory I have /client/build/js/test.js and test.js loads correctly.
Also, there is one more way to do it that is easier and doesn't require mucking about in the kraken source. In your main index.js file you can do this:
app = module.exports = express();
app.use(kraken(options));
app.use(express.static('client')); // Add this line
Days, then weeks, then months went by, and nothing worked.
I should have noted that I am not using Yoeman, and we use gulp at work, which may have been part of the problem.
The solution turned out to be
"middleware": {
"static": {
"route": "/public"
},
which looks very different to any of the documentation from kraken. Hope this helps somebody.

Taking screenshots with Selenium Builder

Using Selenium Builder, I've created the following json file:
{
"type": "script",
"seleniumVersion": "2",
"formatVersion": 2,
"steps": [
{
"type": "get",
"url": "http://stackoverflow.com/"
},
{
"type": "saveScreenshot",
"file": foo.png"
}
],
"data": {
"configs": {},
"source": "none"
},
"inputs": [],
"timeoutSeconds": 60
}
I tried running it on Windows 7 and two different Ubuntu machines. Instead of the filepath "foo.png" I had also inserted "E:\foo.png" / "/home/swege/foo.png". However, I always get the "exception":
Could not take screenshot of current page - [object Object]
At least I would like to be able to read the "error object", but every system just puts out that the error is a JavaScript object. Any idea how to fix the issue or read the full error message?
Try following :
http://www.ontestautomation.com/how-to-create-screenshots-in-your-selenium-webdriver-tests/
Above can help you to get exact code that how you can take screenshots using selenium.
So I pulled down and looked at the source for Selenium Builder 2 and found two files that I think show the origin of the error, command_processor.js and driver_component.js.
I can't make out why the error is occurring - maybe someone here can build on this?
Try using a full file path, not just foo.png. On Mac, these worked for me: ~/foo.png and ~/Downloads/screenshots/foo.png.
It's also important that the folder exists and is writable by the account running the web browser.

Error6 while trying to use sublime text to msbuild

I'm trying to use msbuild with my sublime project. I created the build file suggested here and the following is my project file
{
"folders":
[
{
"path": "/W/MyOrg/MyApp",
"folder_exclude_patterns": ["_ReSharper.*", "bin", "obj"]
}
]
}
I select the msbuild40 build system and hit Build and get the output:
[Error 6] The handle is invalid
[Finished]
I'm not even sure if this is a python or an msbuild error. Which is it, how can I fix it, and whats a good way to troubleshoot this sort of stuff in the future?
Update
I tried updating my project to the following and using that build and still no dice
{
"folders":
[
{
"path": "/W/MyOrg/MyApp",
"folder_exclude_patterns": ["_ReSharper.*", "bin", "obj"]
}
],
"build_systems":
[
{
"name": "msbuild",
"cmd": ["c:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\MSBuild.exe", "w:\\MyOrg\\MyApp\\MyApp.sln"]
}
]
}
Turns out that this happens whenever you start sublime from command line ( I was starting it via a powershell alias).
You can fix this by using a batch file and the START command. I created sublime_text.bat:
START "Sublime Text 2" "C:\Program Files\Sublime Text 2\sublime_text.exe" %*
and set my powershell alias to that bat file. Now everything works.

TemplateDoesNotExist at/

here is my site url http://webtrick.heliohost.org/
my template directory settings:
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__) , 'templates').replace('\\','/')
)
view.py
from django.http import HttpResponse
from django.template import Template , Context
from django.shortcuts import render_to_response
def index(request):
return render_to_response('index.html')
url.py
from django.conf.urls.defaults import patterns, include, url
from webtrickster.views import index
urlpatterns = patterns('',
url(r'^$', index)
)
i don't know what's wrong with this code
any help appreciated
Make sure your Django app is in the INSTALLED_APPS in settings.py. That was my problem with it. So if you have the templates folder in your polls app folder, you need to add the 'polls' at the end of the installed apps in the settings file.
Add you application into setting.py end of the INSTALLED_APPS like below:
INSTALLED_APPS = [
...
'django.contrib.staticfiles',
'mysite'
]
and your templates dir should be in mysite like
mysite
-settings.py
-templates/
I wasted a lot of time trying to figure out what was wrong with my 'templates' directory and found out that :
You may have forgotten to add TEMPLATE_DIR in the following segment of settings.py :
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
So it should have 'DIRS': [TEMPLATE_DIR,], instead of 'DIRS': [],
Also see answers for : TemplateDoesNotExist at /
os.path.join(os.path.dirname(__file__) ,'../templates').replace('\\','/')
That worked for me.
First you need to make one folder named 'templates' in your django project folder then, you can add template directory by two ways open your settings file then add any of the following code
1) You can specify your template path directly by
TEMPLATE_DIRS = (
'D:/Django/web/Kindset/templates' #your file path ,this is my template directory path
)
2) Or if you want to use generic path means use
TEMPLATE_DIRS = (
'os.path.join(BASE_DIR, "templates"),'
)
You may forgot to install you app
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'tutorials'
]
Make sure you also add dirs properly in your templates
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
TEMPLATE_DIRS = (
"mysite/templates"
)
TemplateDoesNotExist - file exists, no permissions issue
My templates folder wasn't a python package because it was missing the __init__.py file.
This might have been the reason why Django was not locating my templates.
Many good answers here, but on updating an old project (nightmare=zinnia, django_cms, AUTH_USER_MODEL = 'accounts.CustomUser') that was not maintained for many moons from django 1.6 to django 1.7 as stage one of a very long process, I found nothing worked. Then I noticed that the errors had quotes around the template it was trying to load:
/home/vagrant/venv/crowd88/local/lib/python2.7/site-packages/djangocms_admin_style/templates/'core/includes/ga.html' (File does not exist)
So I looked at the source and found that quotes are stripped this way:
# lib/python2.7/site-packages/cms/utils/plugins.py
...
template = get_template(force_unicode(node.template).strip('"'))
...
Then I noticed that single quotes were being used in the loaders
{% include core/includes/ga.html' %}
So the fix was
{% include "core/includes/ga.html" %}
using a regex process
Move your "templates" folder to the main and not in any sub folder. Or on the same level as other projects folder. This might have been the reason why Django was not locating my templates.
My project worked after doing this.
make sure your dirs directory in settings.py looks like this
'DIRS': [os.path.join(BASE_DIR, 'templates')],
By default, inside the settings.py file, the 'DIRS' array is empty as you can see below.
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
So to solve the issue, just add BASE_DIR / 'templates' to the array to look like below. And you are good to go.
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [BASE_DIR / 'templates'],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
Go to the settings.py file and check the TEMPLATES section. Notice the DIR value, by default it should be []. Add "os.path.join(BASE_DIR, 'templates')" inside this. It should look like this :
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
I encountered the same error. After checking TEMPLATE_DIR and INSTALLED_APPS a thousand times I noticed a small typo in one .html template:
{% extends "my_app/base.html " %}
should have been
{% extends "my_app/base.html" %}
(notice the white space in the first command)
If you have tried some of the solutions above and it not worked try checking whether the template is within the correct folder.
Template outside of the templates/appname folder:
appname/
|
|__templates/
| |
| |__appname/
| |__appname_form.html
|__appname_list.html <------ outside of the appname/ folder (WRONG)
Like this if you have a url that send to this template, Django will through a TemplateDoesNotExist since the template does not follow the path you placed in TEMPLATES.DIRS.
Try fixing like:
Template inside of the templates/appname folder:
appname/
|
|__templates/
| |
| |__appname/
| |__appname_form.html
| |__appname_list.html <------ inside of the appname/ folder (RIGHT)
Therefore, like this you may fix this exception.
if {% extends "blog/base.html" %} make sure base.html is in the blog folder and not in Templates or any other directory. That solved it for me.
This worked for me:
1.Make a folder in your app called static and create the css file in the static folder
2.Make another folder still in your app called templates and create the html file there
On the first line of your html file write this: {% load static %}
Link the css file inside the head tag as follows: href="{% static 'index.css' %}"
Thank me later.
Got the same problem !
I've already followed all solutions provided above but pfff ! I were lost and maybe someone could face it too!
So I solved it by only
return render(request, 'profile.html')
and not
return redirect(request, "profile.html")
Happy debugging !!!
After debugging a lot, i found out that the path which i was giving in views.py to render the template is wrong so it was showing TemplateDoesNotExist at/ error
for Example the mistake i was making is this
Wrong code :-
return render(request, 'show/index.html', {'product_objects': product_objects})
Right code :-
return render(request, 'shop/index.html', {'product_objects': product_objects})
the app name was shop not show.
Hope it will help someone
I think the answer is pretty simple just give the right path
Use this if you have your templates folder in your app
BASE_DIR = Path(__file__).resolve().parent.parent
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'DIRS': [BASE_DIR,"templates"],