w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Should I unit test my Behat step definitions?
I would try to test any logic used within generic test code. E.g. I wrote a special assert function for phpunit I used in many tests (asserting that two string are equal while ignoring any whitespace differences). I unit tested (actually even TDDed) this logic all the way.

Categories : PHP

When running a Behat login test through PhantomJS it only passes on the first run
Ok, I finally figured this bugger out. At least partially. It seems to be maintaining the session between scenarios. This doesn't fully explain why it is only the first call. But I suspect that PhantomJS is keeping the previous session open when the last scenario closes and that Mink rebuilds the session between scenarios, but not after the end of the last scenario. Anyway, the solution is to create a context or a hook to reset the session at the end of each scenario call. For testing purposes I created a context that reads "And I reset the session". I defined this as such: /** * @Given /^I reset the session$/ */ public function iResetTheSession() { $this->getSession()->reset(); } When I call that context at the end of both scenarios it fixes the problem. So I think I will

Categories : PHP

git + behat: No submodule mapping found in .gitmodules for path 'vendor/behat/gherkin'
As there is nothing in .gitmodules, it means that you have not added the submodule using git submodule add command. Do something similar to the following: git submodule add "external module path" "project directory" After adding if you do git status, you should get .gitmodules configuration file which stores the mapping between project url and local directory. Now if you read the contents of .gitmodules, it should list the mapping. For more information please go through git submodules section in progit book (http://git-scm.com/book/en/Git-Tools-Submodules)

Categories : GIT

Cannot --init the PHP BDD test software 'Behat' on RedHat RHEL/CentOS/Fedora 6.4
DOMDocument is part of the "DOM" PHP extension. If you compile PHP from source, this gets included by default. Enterprise Linux-based systems require more than just the php module to be installed to get a full PHP installation. The second error is caused by a missing multi-byte string module. You can install these manually without having to recompile PHP. To do this using Puppet, add the following to your init.pp file: package { "php-mb": ensure => "5.3.3-22.el6" } package { "php-xml": ensure => "5.3.3-22.el6" } Where the version numbers match the version of PHP you already have installed. This is equivalent to: yum -y install php-mb php-xml Behat will now initialise and run without error.

Categories : PHP

not able to attach a file (csv file) in input field using Behat Mink extension Framework
First method is working for me. Don't forget to use the complete path to the file or use files_path Mink config setting. Check this forum post: https://groups.google.com/forum/#!topic/behat/vxZAssi2Nf8 Mink requires an absolute path to upload a file, but obviously that path probably won't work in other environments. Instead, you can provide a "file_paths" property to your Yaml configuration file: extensions: BehatMinkExtensionExtension: files_path: "path/to/files"

Categories : PHP

Behat Attachment File does not work
Here, this code is the default code of behat and mink. try this. /** * Attaches file to field with specified id|name|label|value. * * @When /^(?:|I )attach the file "(?P<path>[^"]*)" to "(?P<field>(?:[^"]|\")*)"$/ */ public function attachFileToField($field, $path) { $field = $this->fixStepArgument($field); if ($this->getMinkParameter('files_path')) { $fullPath = rtrim(realpath($this->getMinkParameter('files_path')), DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$path; if (is_file($fullPath)) { $path = $fullPath; } } $this->getSession()->getPage()->attachFileToField($field, $path); }

Categories : Misc

Write a file only downloads 1k
You need to verify either your network or the URL you are trying to retrieve; Python will read from the result socket until EOF is reached so if you got less data than expected, you either were sent an incomplete response, the network cut the response short (proxy server, firewall, what-have-you), or your assumption about what the server sends for that URL is wrong. You also want to use shutil.copyfileobj() to do the reading for you: from shutil import copyfileobj im = urllib.urlopen('http://gifs.gifbin.com/082013/tn_1378920172_decapitated_snake_bites_itself.gif') with open('00000001.gif', 'wb') as out: copyfileobj(im, out) This will not only handle reading the data in chunks, but will avoid filling memory with large blobs of binary data to boot. The with statement handles closin

Categories : Python

How Mega downloads a file?
By using either a[download], msSaveOrOpenBlob, or Adobe Flash SWF Filewriter, depending on which method is supported by the browser. PS: MEGA doesn't always use HTML5 FileSystem API. They have various techniques that they use depending on the browser support. In Firefox 20+, for example, they will store the data temporarily to the IndexedDB storage, before triggering the a[download].

Categories : Javascript

How to cache file downloads with AFNetworking?
What you're trying to do has a name and it's caching. AFNetworking already implements it as per the official FAQs Does AFNetworking have any caching mechanisms built-in? AFNetworking takes advantage of the caching functionality already provided by NSURLCache and any of its subclasses. So long as your NSURLRequest objects have the correct cache policy, and your server response contains a valid Cache-Control header, responses will be automatically cached for subsequent requests. Set up the cache as follows and you'll be ok - (void)setupCache { NSURLCache *urlCache = [[NSURLCache alloc] initWithMemoryCapacity:1024*1024*4 // 1MB mem cache diskCapacity:1024*1024*5 // 5MB disk cache

Categories : IOS

Gradle downloads pom.xml but not the .jar file for Cucumber
cucumber-jvm is the parent group cucumber.api.cli.Main requires cucumber-core Use below: dependencies { compile "info.cukes:cucumber-core:1.1.3" } This will download the required jar.

Categories : Gradle

Checking the number of downloads for a file
I think you should try an Apache rewrite rule , for instance, you could rewrite every request to any .exe file to be redirected to a php as a parameter. Then you can use the mechanism you designed (MySQL records in a database).

Categories : PHP

Listening for downloads from browser/getting name of downloaded file
You have to use a BroadcastReceiver (After api 9). Like this: BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (DownloadManager.ACTION_DOWNLOAD_COMPLETE.equals(action)) { long downloadId = intent.getLongExtra( DownloadManager.EXTRA_DOWNLOAD_ID, 0); Query query = new Query(); query.setFilterById(enqueue); Cursor c = dm.query(query); if (c.moveToFirst()) { int columnIndex = c .getColumnIndex(DownloadManager.COLUMN_STATUS); if (DownloadManager.STATUS_SUCCESSFUL == c

Categories : Java

Going to a URL downloads a file but AJAX returns 403. Why and how would we resolve?
Check and double check the CORS. The others in my group were looking around, and it seems that the file was not set up correctly for CORS, whereas other files i was pinging DID have the permissions set up. After this was checked, fixed, etc, i used the call again and everything was now working. I did not have perms to look at that server data so I was hoping it was right to begin with.

Categories : Javascript

2 Progress Bars for multiple file downloads
To have a second progress bar that tracks total bytes downloaded: Prior to showing the download screen, determine the total number of bytes to be downloaded. The specifics here depend on the download mechanism, but most FTP and HTTP servers will provide file sizes. In cases where they don't you'll have to make a reasonable estimate. Store this in an accessible member variable. Create an accessible member variable for the total number of bytes downloaded. Bind this to the same routine that updates your single-file progress, so that each download "tick" also accumulates the "number of bytes downloaded" field in addition to the percentage of the current file as it does now. Bind the total number of bytes to the "total percentage" progress bar maximum value. Bind the bytes downloaded counte

Categories : Vb.Net

How to handle conditional file downloads in meteor.js
Three easy steps: use meteorite add the iron-router package: mrt add iron-router create a server method to serve your file. Here is how an exemple: Router.map(function () { this.route('get-image', { where: 'server', path: '/img', action: function () { console.log('retrieving ' + this.request.query.name); this.response.writeHead(200, {'Content-type': 'image/png'}, this.request.query.name); this.response.end(fs.readFileSync(uploadPath + this.request.query.name)); } }); }); In this example the request is a HTTP GET with one parameter name=name-of-pdf.pdf. That's really all. Hope it was what you were looking for.

Categories : Node Js

File downloads not working in chrome which have Pepper-Flash 11.8.800.115
Had the same issue. Try use ExternalInterface. In html in the JS section: function downloadFileFromAS( _fileURL ) { window.location.href=_fileURL; } In AS3: if( ExternalInterface.available ) { ExternalInterface.call( "downloadFileFromAS", fileUrlGoesHere ); } Remember to set allowscriptaccess = "always" in html It looks like it works at least for me. Greg

Categories : Actionscript

How would I create a Python web server that downloads a file on any GET request?
Try following: import BaseHTTPServer import os import shutil import sys FILEPATH = sys.argv[1] if sys.argv[1:] else __file__ class SimpleHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): def do_GET(self): with open(FILEPATH, 'rb') as f: self.send_response(200) self.send_header("Content-Type", 'application/octet-stream') self.send_header("Content-Disposition", 'attachment; filename="{}"'.format(os.path.basename(FILEPATH))) fs = os.fstat(f.fileno()) self.send_header("Content-Length", str(fs.st_size)) self.end_headers() shutil.copyfileobj(f, self.wfile) def test(HandlerClass=SimpleHTTPRequestHandler, ServerClass=BaseHTTPServer.HTTPServer, protocol="HTTP/1.0"): if

Categories : Python

File downloads black file
Your script is just sending the headers, you should readfile also before ob_clean(). For instance it could be: if (file_exists($fmain)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename($fmain)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: ' . filesize($fmain)); readfile($fmain); ob_clean(); flush(); exit; }

Categories : PHP

Android: how do I intercept when the user downloads a file (from the browser or from the email or form other source)
I found this link: Intercepting links from the browser to open my Android app You can intercept the link like explained in the answer. Once you've got the link, it is up to you how to handle it through code. If you want to download it with your own applications to a folder you desire, you can use following codes: Download a File In Android From Remote Server How to download file/image from url to your device I hope these will help you.

Categories : Android

Browser requests file, server downloads pdf, browser displays pdf in iframe
Probably what you meant was simply: var uri = '/viewer/loaddrawing/'; document.getElementById('iframetitle').src = uri + '?key=' + value; There is no JSON involved, so the iframe will get a PDF directly. However, notice that the client must have a PDF-viewer plugin, otherwise the browser will ask for a download prompt.

Categories : Javascript

Error "Unable parse file browser.yml" when running a test with Magento automation test framework
I've resolved this by upgrading the Symfony Yaml package to the latest version: pear channel-discover pear.symfony-project.com pear install symfony/YAML Seems that the "---" syntax is supported on v. 1.0.6 (the latest stable at this moment).

Categories : Magento

NIO load file in an unit test from src/test/resources
Well, it's a matter of obtaining the correct Path for you test resource in the classpath in your test. EDIT: this is more concise: Paths.get(getClass().getResource("/"+filename).toURI()).toString()

Categories : Java

How to use Behat with CodeIgniter?
Download here Behat CI Test Simple test with Behat and CodeIgniter. The CodeIgniter controller just displays a login page and returns a data array that use to make assertions. There are various debug statements printed with error_log, which Behat displays on stdout, to follow the flow of execution.

Categories : Codeigniter

Trying To Set Up Selenium + Behat On Mac
You should configure your wd_host and wd_parameters under the selenium2 section, not parameters: default: extensions: BehatMinkExtensionExtension: selenium2: wd_host: 127.0.0.1:4443/wd/hub capabilities: browser: firefox version: 21 Double check if wd_host and wd_capabilities are correct parameter names.

Categories : PHP

Parameters in behat.yml
Behat configuration is in no way related to Symfony's. It's true that Behat uses Symfony's DI container, but it's a separate instance. If wanted to implement it, you'd probably need to create your own Behat extension to support the imports section.

Categories : Symfony2

Behat : Error using switchToIFrame()
After many try, I have find the answer. For any behat's functions, the methods can put any types of arguments (id, class, name, ...). For the method switchToIFrame(), the method put only the element's NAME !!! In more, I have not been able to use the method with only Behat/Mink. I use now Selenium2 server and I added '@javascript' in my file.feature. Feature: Homepage @javascript Scenario: Check if I can log on Given I am on "/" ... It works !

Categories : Symfony2

Zombie.js with Behat and Mink
Same issue when trying to simulate a $nodeElement->mouseOver() with Mink/Behat/Symfony2.1 TypeError: Parameter 'url' must be a string, not object at Url.parse (url.js:107:11) at urlParse (url.js:101:5) at Object.urlResolve [as resolve] (url.js:405:10) at Object.iframe.setAttribute (/usr/lib/node_modules/zombie/lib/zombie/jsdom_patches.js:164:43) at attrCopy (/usr/lib/node_modules/zombie/node_modules/jsdom/lib/jsdom/level1/core.js:331:14) at Object.core.Node.cloneNode (/usr/lib/node_modules/zombie/node_modules/jsdom/lib/jsdom/level1/core.js:636:18) at Object.core.Node.cloneNode (/usr/lib/node_modules/zombie/node_modules/jsdom/lib/jsdom/level1/core.js:706:37) at Function.jQuery.extend.clone (/js/2225e47_jquery-1.8.2_2.js:6222:17) at Function.jQuery.extend

Categories : Javascript

How to select a driver in Behat?
you have to define "default_session: goutte" in your "BehatMinkExtensionExtension" section. then define sahi_session: sahi now you will be able to switch session inside feature file like this: Feature: Category Add Category, change Category @sahi Scenario: Change Category, add new Category ....

Categories : PHP

Behat with Jenkins or Maven?
The simplest way to get jenkins running your behat suite is to use a shell script. Providing you've got a PHP environment setup on your jenkins host and the project dependancies installed through composer, you can specify a simple command such as bin/behat. This will run your behat feature suite, returning an error code if the suite fails. Jenkins should pick this up and fail your job too. In my experience, having a specific profile in behat.yml for specifying formatters and parameters is useful. As a result your command may look something like: bin/behat --profile ci You can of course wrap these commands in something like maven or rake and instead of running a shell script in your jenkins job, you can invoke a rake/maven etc task. I use rake for my projects as it's much easier to mainta

Categories : PHP

Jenkins and Behat profile
i think You should add profile parameter in your build.xml, it's looks like behat --profile ios behat documentation

Categories : PHP

Why behat fails to run in windows 7?
To run php binehat you would have to already be in the C:Behat folder. To run php behat you would have to already be in the C:Behatin folder. Your search path is only good for the php executable, not its parameter list.

Categories : PHP

cant write features in French in Behat
Look at the configuration details in: [project root]/vendor/behat/gherkin/tests/Behat/Gherkin/Fixtures/i18n.yml You can also look in: [project root]/vendor/behat/gherkin/i18n.php Make sure you are using the correct syntax for it. Have you tried using the following just to see if it will work when specifying the language from the command prompt? $ behat --story-syntax --lang YOUR_LANG From: http://docs.behat.org/quick_intro.html#more-about-features Also please provide us with examples of what you are doing. It is kinda hard to troubleshoot something you can't see or analyze.

Categories : PHP

behat undefined step although it should be defined
I'm sorry , there were a couple of mistakes I was making ....I did not create the features directory , instead was adding my features to the vendorehatehatfeatures directory and the step definitions to vendorehatehatfeaturesootstrapFeatureContext.php To make it work I had to create features directory in root of project by typing vendorehatehatinehat --init in command prompt All features should reside in this directory and steps should go in rootfeaturesootstrapFeatureContext.php Further the uri should be 'http://'.localhost/Project/.$page in $session->visit() Hope this helps someone!

Categories : PHP

Behat and Symfony2 bundle issue?
Either Behat can't find your configuration, try specifying it like so: bin/behat -c alternative/location/to/behat.yml --init "@CompanyAppBundle" Or you haven't enabled the Symfony2Extension in your (default) configuration, try specifying it like so: default: extensions: BehatSymfony2ExtensionExtension:

Categories : PHP

behat Selenium2Driver "could not open connection"
Firstly, you didn't configure selenium driver properly. It should be: default: extensions: BehatSymfony2ExtensionExtension: mink_driver: true BehatMinkExtensionExtension: default_session: 'symfony2' base_url: http://localhost/fhm_mind_solution/app_dev.php/ selenium2: wd_host: 'http://127.0.0.1:4444/wd/hub' capabilities: { "browser": "firefox", "version": "23"} Secondly, you don't have to initialize the driver nor the session yourself. It's done for you by the MinkExtension. Simply make that your context extends the BehatMinkExtensionContextRawMinkContext and you'll get access to the $this->getSession() method. Read more in the official docs: http://extensions.behat

Categories : Symfony2

How can i specify an order in mink/behat tests?
Behat executes files in an alphabetic order. You could prefix them with a number to force the order. However... Scenarios are meant to be independent and the execution order shouldn't matter.

Categories : Testing

stange error with Behat and Mink on Sf2
I had the same problem. Forgot you need to install behat/mink-extension as well as behat/mink. For example you might need to run: php composer.phar require behat/mink-extension:* Worked for me. By the way, looks like you got confused by the two installation methods, phar vs composer. I'd go with the composer route because it's easier to update and manage versions. This would mean running php bin/behat ... instead of php behat.phar ....

Categories : Symfony2

codeception with ms sql? Behat support for mssql?
Behat itself doesn't have anything to do with databases. If you need connecting to one from a Behat context file, you just use whatever is used in your application. I've successfully used Doctrine with Behat for example, also with mssql. For mssql integration you will need the doctrine-pdo-dblib package.

Categories : Sql Server

Nunit loads all test Test data for all the test before the test gets executed
I think that's by design. NUnit is designed to clean up the environment before any test, to generate same conditions for any test independent their execution order. If Test A would change the XDocument, Test B would be run with that changes. That might led to indeterminate test results. If Test B expects changes made from Test A, then your tests are not fully isolated, that's a bad practice. If you wan't to change that behaviour, implement a lazy field and load the test data only on first access. You can increase performance if you know that you are not changing data in any of your tests, but pay attention. private static Lazy<IEnumerable> testData = new Lazy<IEnumerable>(GetExample); private static IEnumerable GetExample() { var doc = XDocument.Load("Example.xml");

Categories : Xml

How to find a symfony 2 field in Behat/Mink
What I understood with gherkin is, it shows what's wrong with our design and UX. And if we can't tell the program what field fill, how a human could he? Also the main purpose of your scenario is not to fill the form but add a city. So you should change Then by And on the line Then I fill in "name" with "Testing 1 2 3". On the other side, you can simply add a specific validation method and keep a readable feature, something like : And I fill the city's creation form field with "Testing 1 2 3" Then in your context : /** * @Given /^I fill the city's creation form field with "([^"]*)"$/ */ public function fillCitysCreationForm($arg1) { $this->fillField('my_project_localebundle_citytype_name', $arg1); } PS: I didn't test the previous code, you may have to improve it.

Categories : Symfony2



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.