Using rspec-rails-3.5.2, poltergeist-1.11.0, and capybara-2.10.1
I created an audio object:
Bart.pumpAudio = new Audio("assets/audio/bart/pump.mp3");
I have a button that plays a sound when pressed
<div id="pump-button" class="button">Pump</div>
$("#pump-button").click(function() {
...
Bart.pumpAudio.play();
...
});
It works when I run on a browser, but I get errors when trying to perform tests through rspec:
Testing Code:
page.find("#pump-button").trigger('click')
Testing Error:
TypeError: 'undefined' is not a function (evaluating 'Bart.pumpAudio.play()')
Any ideas on how to solve this??
Adding this to the top of my js file seemed to solve my issue
var Audio = function() {
return {
load: function() {},
play: function() {}
}
}
Source
Related
topBarClient.request(settings).then(
function (data) {
console.log("data",data);
showTaskData(data);
if (data.status === 200) {
onSuccess(JSON.parse(data.responseText));
} else {
onFailure(data.status);
}
},
function (response) {
console.log("error", response);
onFailure(response.status);
}
);
onFailure is working but not able to get the error out
Is there a way to test this locally?
console.log works fine, if it's not working then it is not getting called probably due to some exception in the line above console.log.
If you face any problem you can render html component like div to dislplay the text for debugging purpose.
First of all, I'm quite new to NativeScript and e2e testing, but I'm trying to get some simple tests to run on my demo application. I did the whole setup where I installed everything and an e2e (default) folder + files were created.
I have this demo app layout where I basically have one button:
<ActionBar title="My App" class="action-bar">
</ActionBar>
<GridLayout class="page">
<StackLayout>
<Button automationText="testButton" text="Button"></Button>
</StackLayout>
</GridLayout>
These are my tests:
import { AppiumDriver, createDriver, SearchOptions } from "nativescript-dev-appium";
import { assert } from "chai";
describe("sample scenario", () => {
const defaultWaitTime = 5000;
let driver: AppiumDriver;
before(async () => {
driver = await createDriver();
});
after(async () => {
await driver.quit();
console.log("Quit driver!");
});
afterEach(async function () {
if (this.currentTest.state === "failed") {
// await driver.logTestArtifacts(this.currentTest.title);
}
});
it("should find an element by text", async () => {
const btn = await driver.findElementByText("Button");
assert.isTrue(btn.exists());
});
it("should find an element by automation text", async () => {
const btn = await driver.findElementByAutomationText("testButton");
assert.isTrue(btn.exists());
});
});
I had to comment this line, otherwise, my tests wouldn't finish (I had to manually stop them with ctrl C):
// await driver.logTestArtifacts(this.currentTest.title);
I am running it with:
$ npm build ios
$ npm run e2e -- --runType sim.iPhone6
I am able to run stupid tests, assertTrue(true), but when I am trying to access an element, the button, things go wrong:
should find an element by text:
[waitForElementByXPath("//*[#label='Button' or #value='Button' or #hint='Button']",5000)] [elements("xpath","//*[#label='Button' or #value='Button' or #hint='Button']")] Not JSON response
Error: [elements("xpath","//*[#label='Button' or #value='Button' or #hint='Button']")] Not JSON response
at exports.newError (node_modules/wd/lib/utils.js:151:13)
And:
should find an element by automation text:
[waitForElementByAccessibilityId("testButton",5000)] [elements("accessibility id","testButton")] Not JSON response
Error: [elements("accessibility id","testButton")] Not JSON response
at exports.newError (node_modules/wd/lib/utils.js:151:13)
I also tried to see if the driver was just empty or something like that, but isIOS and isAndroid work fine.
I don't know if this has something do to with it but when killing the driver this error also pops up:
Error: [quit()] Unexpected data in simpleCallback.
If anybody could help that would be great! Thanks!
There seems to be a similar issue logged in at the {N} Appium Github repo, the problem seems to be the environment setup, at least in their case it was not installing carthage.
Did you go through the setup process here, made sure you have everything in place?
I am trying to use preloadjs to load mp3 file. I also use HTMLAudioPlugin in Soundjs, but when I want to get the audiodom as use getResult function, it doesn't work in ios but not in chrome.
preloadManifest = [{src: "bgm.mp3", id: 'bgm', type:'createjs.AbstractLoader.SOUND'}]
createjs.Sound.registerPlugins([createjs.HTMLAudioPlugin]);
loader = new createjs.LoadQueue(true, null, true);
loader.addEventListener('complete',function () {
loader.getResult('bgm') // undefined in ios
});
I created export contextButton with menuItems like this.
'exporting':{
'buttons': {
'contextButton': {
'menuItems': [ {
'text': 'Export to PNG',
'onclick': function() {
this.exportChart();
},
'separator': false
},null,null,null,null
]
}
}
}
When click the menuItem, chrome & firefox works fine but IE got following error in highcharts.js and cannot open the menu:
Invalid argument. highchart.js, line8 character56.
(function(){function N(a,b){var c;a||(a={});for(c in b)a[c]=b[c];
Any idea about this issue?
Also in chrome&firefox, "print" works fine. However any download like download png, download pdf not working. And I got below error in exporting.js when I click:
Uncaught TypeError: Cannot read property 'style' of undefined.
Any idea about this?
I'm using the Soundcloud Javascript SDK (http://developers.soundcloud.com/docs/api/sdks#javascript) on a project and have happily got my player loading a sound and playing it like so:
SC.get("/resolve/",{
url: href
},function(response){
SC.stream("/tracks/"+response.id,{},function(sound){
sound.play();
});
})
I can trigger the soundmanager object to play in the callback using sound.play() but I can't work out how to access the events of the object mantioned in the docs (http://www.schillmania.com/projects/soundmanager2/doc/) like whileplaying()
How do I add these in? I've tried this kind of thing:
sound.whileplaying(function(){
alert("hooray!")
})
But that doesn't work.
Many thanks
Julian
This should work:
SC.stream("/tracks/" + response.id, {
whileplaying: function () {
console.log("track is playing");
}
}, function (sound) {
sound.play();
});
The correct way is:
SC.stream('/tracks/' + response.id).then(function (player) {
player.on('finish', function () {
console.log('finish');
});
player.play();
});
You found this answer and consult all events here:
https://developers.soundcloud.com/docs/api/sdks#player