Change Img src value with phantom js - phantomjs

I'm trying to change a src element in an img tag with phantom js and for some reason I can't get it. I've checked all over google and info on this is scarce. Here's what I've tried:
document.getElementById("licensePlateImg").setAttribute("src", "blahblahblah.jpg")
This one I didn't think would work but tried any how:
document.getElementById("licensePlateImg").img.setAttribute("src", "blahblahblah")
no success with this either.
document.getElementById("licensePlateImg").find("img").attr("src", "blahblahblah");
This is the div I need to change:
I can't use jquery for this.

Related

How to reference style tag element in Vue.js

When creating a Single Page Application, I have had the need to reuse CSS as a string.
The need was from a library requiring passing CSS as a string and needing to also use that CSS in the page.
To achieve this, I went through 2 routes, and both failed. Referring to the style tag element should be simple, so I'll focus on this in this issue, but if anyone can solve the other route, please let me know. Regards.
Attempted routes to solve issue:
Reference style tag element. Couldn't get this to work. Even has problems using global querying because of build process destroying ids.
I tried using raw-loader to directly import, but failed. I am using Typescript so tried to import as a string but failed again.
I was able to fix my main goal of reusing the same CSS by using external css in the style tag and importing the css as a string using raw-loader.
import css from !!raw-loader!./my-css.css
...
<style src="./my-css.css">
I still do not know how to get a safe reference to the style tag, but the above solves my issue.
* The reason for the style tag not being easily referenced even via document.querySelector is that the build process seems to strip attributes.

apply downloaded CSS on windows 8 metroUI app

I have to download CSS file and apply style sheet to my app. I downloaded this file at the local folder and referenced it as
style.href = "ms-appdata:///local/css//custom.css";
and appended to head as
document.getElementsByTagName('head')[0].appendChild(style);
after document onready event.
Seems it has no effect (but I can see this element in the dom browser).
So is there any restriction for css source: app package, local folder? May be this impossible to reference downloaded CSS due to MS limitations? Or may be I'm doing something wrong? Any suggestions?
Do keep in mind, however, that you can access the document.styleSheets collection and list, add, or remove CSS rules dynamically from JavaScript. You can access the individual rules themselves through the DOM using statements like document.styleSheets[0].cssRules[0].style.color = "red" or you if you've fetched yourself some custom CSS text (dynamically from your other CSS file online) you can add its styles to one of your active style sheets using something like document.styleSheets[0].cssText = "{my CSS code}". Do be sure that you're manipulating the right style sheet by checking the document.styleSheets[0].href.
I think you're out of luck trying to head down that path.
Note that, for security reasons, you cannot navigate to
HTML you have downloaded to this location and you cannot
run any executable or potentially executable code, such
as script or CSS.
Source: http://msdn.microsoft.com/en-us/library/windows/apps/hh781215
Also, this blog post seems possibly helpful: http://palermo4.com/post/How-to-Use-IFrames-in-WinRT-Apps.aspx

Is it possible to get the absolute URL of an image that is called by CSS in Selenium IDE?

I am wondering if it is possible (but I have a hunch it's not..) to retrieve the absolute URL of an image that is loaded by a specific CSS class.
For example:
<div class="rabbit">
rabbit in css has a background image... how do I get that background image URL?
The reason why I ask on how to do this in Selenium IDE is because in my company we use it.
I am still googling and since I am not very proficient at JS, I could easily be missing a simple solution!
here's a quick pointer
You'll need to use storeEval to run some js and store the value, so look at the Selenium IDE docs for that
Then the js will be something like this...
getComputedStyle(document.getElementById('hireme'),'').getPropertyValue('background-image');
if you run the snippet above, in the console on this page you should get something like this...
"url(http://careerscdn.sstatic.net/careers/gethired/img/careers2-ad-header-so-crop.png)"
Which will hopefully be good enough for any asserts you want to make
You'll need to replace the document.getElementById('hireme') with document.getElementsByClassName('rabbit')[0];
Hope this helps, use comments if you need any clarification.
You may also need to add this.browserbot.getCurrentWindow(). before the call to document.getElementById

Dojo 1.8: Seems that there's no way to load dojo file into contentpane, is it?

Hi I have tried every ways and means to load dojo page into ContentPane.
It seems That I am not able to do that. Correct me if I am wrong.
Looks like the only solution is through the creation and destroy of any widget while running
Clement
The dojo docs for dojox/layout/ContentPane (which allows references to script files) mentions your issue:
NOTE that dojo.require in script in the fetched file isn't recommended Many widgets need to be required at page load to work properly
#see http://dojotoolkit.org/api/1.8/dojox/layout/ContentPane
It looks like you just need to require these files in the parent widget.

Facebook Application Link and JS SDK

Hello guys I have two small questions about my facebook application link and JS SDK. So let me explain:
1- Well as I understood from Facebook JS SDK, the should be left just empty. But still I am a little dizzy and I want to make sure whether we should put our page content into it or it should be left empty?
Please make me sure about it.
2- I have put some changes in my css and markup of my page but after one day I can not see some of the changes in my facebook application link.
How can I see the result of changes if there is such a way??
Thank you very much indeed.
Let me answer this for you:
1) Yes, It should be left empty and here's the info on why it's required quoted from JS SDK docs:
The JavaScript SDK requires the fb-root element in order to load properly and a call to
FB.init to initialize the SDK with your app ID correctly.
The fb-root element must not be hidden using display: none or
visibility: hidden, or some parts of the SDK will not work properly in
Internet Explorer.
The SDK inserts elements into fb-root which expect to be positioned
relative to the body or relative to an element close to the top of the
page. It is best if the fb-root element is not inside of an element
with position: absolute or position: relative. If you must place the
fb-root element inside of a positioned element, then you should also
give it a position close to the top of the body or some parts of the
SDK may not work properly.
2) It's most probably a cache problem, there's a similar question with an issue of css which has been answered previously: Caching for css content for iphone FB APP
Also to get your browser/visitors browser to re-fetch your CSS file, The trick is to pass a query param/variable at the end of the CSS file url like so: ?v=1
<link rel="stylesheet" href="css/style.css?v=1">
This will automatically make your browser or maybe even facebook to fetch your CSS file again with the new changes. Make sure to change the number everytime you update your files so you could see the changes instantly.