CsQuery Remove not working - csquery

Isn't this supposed to remove all Divs? It is not working for me.
CQ cq = CQ.CreateFromUrl("http://www.ebay.com");
CQ newCq = cq["body"].Remove("div");
string htmlCode = newCq.Render(); //The rendered code shows Divs present
Thanks

When you pass a parameter to Remove it's a filter, not a context-type selector, see http://api.jquery.com/remove/
So this code is only going to match div elements that are directly members of the selection, which only has one member, body.
To remove all divs that are within body:
CQ newCq = cq["body div"].Remove();

Related

Selecting elements by text with CSS3 selectors in CasperJS

I'm doing functional testing using CasperJS's test class, and can't seem to select elements by their text values. My goal is to check that a class of div is visible, and then check it has the value I expect.
I've tried using the CSS3 selectors mentioned on CaspersJS' selector page, but must be doing something wrong. None of the following work for me (all enclosed in ""):
div#myid[text()='sometext']
div#myid[text='sometext']
div#myid[text=sometext]
div#myid:contains('sometext')
div#myid:contains(sometext)
Any pointers as to how I can select a specific element based on it's text value?
Try:
var x = require('casper').selectXPath;
this.test.assertExists(x('//*[#id="myid"][text()="sometext"]'), 'the element exists');
Thanks for the comments above - I ended up going with using jQuery (as it was being loaded on the client) through evaluate() calls in the CasperJS tests.

Replicate chrome webstore a element effect

This one is bit tricky ,
I created jsfiddle here
http://jsfiddle.net/WXmcL/10/
to kinda replicate the https://chrome.google.com/webstore/category/home
addons containers. all is fine except that a element link.
I need to position the
<a class="link" href="linktoapp"></a>
correctly but also let the users reach the
Info1
since I cant have any ul or divs inside the a element I am not able to achieve this effect. Yes I can do spans but my ratings contain ul , divs etc and I would have more markup inside it. If you check on chrome store you can always link to the app and in same time reach the rating. They put all the elements inside the a tag but the page validation is not seeing it. So it seems to me that is being done with js on load or ?
Thank you!
you should forget about validation whilst you are building your effects for a while. get it to work with the markup you need, then you can sit back and take away what won't validate and inject it via javascript.
mootools has a wonderful Element constructor.
new Element("a.linktoinfo[html=Info]").inject(element);
you can pass on any property into it via the constructor options object.
eg.
new Element("a", {
"class": "foo",
"href": "#",
"events" : {
click: function() {
showInfo(this.getParent());
}
}
}).inject(element.getElement("a.link", 'after');
etc etc.
btw when you morph classes, just make sure it morphs the properties you differ. in your case, it makes sense to make .myInfoOn / .myInfoOff that have the different heights. there is no point in assigning a morph between other values that have not been changed.
that type of morph parses all the css rules defined in the class that you pass on every event and in reality, you are better off setting it manually. it will scale less if it's hardwired, I realise that - but you can set as a variable into your class.

Help with CSS seclectors for usage with selenium

<div id="footerSearchInputDefault" class="defaultText" style="visibility: hidden;">Search myTwonky</div>
With respect to selenium, in the above, what is
attribute
element
value
text
label
I keep getting confused between these terms and the explaination of the above example would help a lot.
Thanks.
Element: <div></div>. This is the basic block, everything else is added to the element.
Attribute: id, class, style. Attributes are any extra information added inside the element's tag.
Value: None in your example. Value is a special attribute that form elements have. A browser usually uses the value attribute to transmit data when the form is submitted (think of a username-password form)
Text: Search myTwonky. This is anything wrapped by the element tags.
Label: None in your example. A label is a special element that usually goes before an input element (again in a form). This is usually something like "Password:" which as the name suggests, is a label for an input field in a form

How to remove undesirable text/HTML tags from FLEX LineChart's custom dataTips?

I wrote a function to override my FLEX LineChart's datatips because the default datatips were ugly and rather boring.
I finally set the style I wanted but am now having some problems removing un-necessary tags from being displayed in the custom datatips.
For example, the datatips now display things like this:
"<b>Humidity</b></BR>2010-07-05T00:15:00"
I can always perform a "Replace()" to remove those break and bold HTML tags, but that seems really un-necessary and anti-development.
I am using this to set the dataTip's label text:
var hd:HitData = value as HitData;
var item:LineSeriesItem = hd.chartItem as LineSeriesItem;
_xAxisText = String(hd.displayText + ' ' + item.xValue);
Why is [displayText] displaying HTML tags I must parse out? How can I format those tags out of my text's value? Is there a setting?
I understand the HTML tag's purpose, although they are not being used by FLEX (apparently). I just dont understand how to remove them from the text. I already set my style attributes in the container, which I think would override these tags? Could that be why they are appearing?
Any ideas or suggestions? Thanks!
Flex should definitely be using the HTML tags to format your dataTip. Check this article.
Because you are seeing HTML tags in your dataTips, I am wondering if you perhaps implemented the dataTipFunction incorrectly. If you are able to, you should post a little bit more code.

Applying style using javascript doesn't work always

I am applying style to div using JavaScript it appears well at the first time but when I click an image to open a virtual window the applied CSS goes away.
How can I apply style using script that stays forever.
**There is no way left for me to apply any style at design time because I am using ready made user control and I get ID for the DIV only at run time.
Any Idea??
Here is the script I am using...
window.onload = changeDivOverflow;
function changeDivOverflow()
{
var treeDiv = document.getElementById('T_ctl00contentMainctl04tvw');
treeDiv.style.overflow = "auto";
}
Since you are using ASP.NET, but I cannot see all your full code, I can only assume that your DIV has a runat="server" tag and that's why you cannot get the ID on the client side.
If this is the case, you may consider the following change to get the treeDiv:
var treeDiv = document.getElementById("<%= tvw.ClientID %>");
All styles you apply using javascript and DOM calls, apply only to element you are applying it. In your example it will be only element with ID = 'T_ctl00contentMainctl04tvw'
If you want to reuse that style for more than one element, you should create a CSS class and store that style there. Then apply that class for every element you want. If you want to do it with script, then you should:
var treeDiv = document.getElementById('T_ctl00contentMainctl04tvw');
treeDiv.className = "your-class";

Resources