Is iti possible to find an element by a custom attribute? - intern

All elements in my web application are like that: <div id="12ZD34" test-attr="elt1_stop2_3"> .
The id is automatically generated and change for each execution but not the test-attr attribute.
Is it possible to find testing elements by a custom attribute or an xpath from a custom attribute?
Thanks for any help.

Use jQuery:
$('div[test-attr="elt1_stop2_3"]')

XPath would be:
//div[#test-attr='elt1_stop2_3']

You could use LeadFoot's findByXpath:
this.remote.findByXpath("div[#test-attr='elt1_stop2_3']")

Related

Cannot identify the object in Selenium

I cannot identify the object of the icon showed in the attached screen shot. I have shown the HTML code as well.
The ID's are getting changed dynamically.
Can anyone guide on how to identity this kind of objects in Selenium?
If the ID is always changed, I recommend using CssSelector instead.
For instance,
<div id="running_number_12345" class="icon something">...</div>
You can use locator
driver.FindElement(By.CssSelector("div[class*='icon something']"));
If your icon doesn't have any specific css pattern, I recommend adding something in class attribute. If not, you have to use complex CssSelector to find it.
Try this
driver.findElement(By.cssSelector(".icon something"));

D3: selecting `foreignObject` in with tag is not working but with class

I've a <g>tag and a with a <foreignObject> child tag.
I use D3 to build them and also update them.
I can easily get update the attributes on the <g> tag, but Ive problems to reach the <foreignObject> tag. I can not get with with .select('foreignObject') or .select('foreignobject')!
Not working example with.select('foreignObject') : http://jsbin.com/efiDiCAB/4/edit
When I use a class to get the foreignObject it is working : http://jsbin.com/efiDiCAB/5/edit
Is there a way to get the foreignObject without setting a class on it?
If not, what is the reason for this behavor?
Thanks.
Not working because a bug in Bug in Webkit: Unable to select <linearGradient> with D3.js in Chrome
Thanks #lars-kotthoff

Element like Literal in Ext.NET

Is there an element like asp:literal in Ext.NET to push string elements inside the tag? I am trying to implement a treeview and I get some data in JS. I want to pass this string into ext:TreePanel tag by an element like literal. Is there any tag using in ext.net like this?
The <ext:Label> might be your best best. You can set the .Html property.
Example
<ext:Label runat="server" Html="<h2>Hello World</h2>" />
Hope this helps.

JSF Navigation with Different CSS Class for Current/Active Path

I'm trying to create a menu template in JSF where the link for the current directory has a different "current" or "active" class. The code currently looks like:
<ul>
<li><h:outputLink value="#{request.contextPath}/a/">A</h:outputLink></li>
<li><h:outputLink value="#{request.contextPath}/b/">B</h:outputLink></li>
<li><h:outputLink value="#{request.contextPath}/c/">C</h:outputLink></li>
</ul>
I'm thinking of using something like styleClass="#{(thisDir == currentDir) ? currentLinkClass : normalLinkClass}". But how do I get the current path? Is this even correct, or is there a better way to do this?
Also, I want the links to base on the current path, not just the page. For example, myapp/a/1.jsf and myapp/a/2.jsf (that is, myapp/a/*.jsf) should trigger the active class for the A link. (I hope my explanation is clear.) Is this possible? How should this be done?
Thank you very much!
You can use #{request.requestURI} to get the current request URI. You can if necessary use several EL functions from JSTL fn taglib to do some string comparisons/manipulations in EL.
Your proposed EL styleClass suggestion is perfectly fine. There is no other easy way anyway. Best optimization which you could do so far is to render those links in a loop by an <ui:repeat> so that code duplication is at least eliminated.
You can also try this approach which uses #{view.viewId}:
<h:outputLink
styleClass="#{(view.viewId.equals('/admin/authors.xhtml')) ? 'active' : 'inactive'}"
value="authors.xhtml">Text</h:outputLink>

Using resource files in SharePoint MasterPages

I haven't been able to figure out how to use strings from resource files (resx) in SharePoint master pages.
I know how to use it with server controls, but can I somehow extract a value and use it in generalt html. I.e. in an alt attribute on a img tag?
<img src="photo.jpg" alt="my_resource_entry_here" />
Here are 2 very good blog posts that describe how to use resources:
http://tomblog.insomniacminds.com/2008/02/25/sharepoint-internals-resources/
http://www.mikhaildikov.com/2007/03/sharepoint-resources-types-use-and_2163.html
The easiest way would be to add a runat="server" attribute to your alt tag. That will solve your problem and you can use the "normal" way of getting resources.
Othwerwise use this syntax to get value from the resx files places in App_Global resources:
<img src="photo.jpg"
alt='<%=this.GetGlobalResourceObject("Global", "Mystring").ToString()%>'
I assume you have a class with a method that lets you get the resource string by the key, e.g. MyResources.GetString(key). In that case you can use something like this:
<img src="photo.jpg" alt='<%=MyResources.GetString("my_resource_key_here")%>' />

Resources