I have a navigation menu in which I wish to bold certain areas of the menu using an injection script.
I wish to use a generic xpath to bold each of the items in the menu that I want.
Problem is, the menu has some selections of the same name that I do not bolded, all in one particular sub-menu.
The menu would look something like this:
<ul class="main-menu">
<li class="sub-menu">Employees</li>
<ul>
<li>Address List</li>
</ul>
<li class="sub-menu">Clients</li>
<ul>
<li>Address List</li>
</ul>
<li class="sub-menu">Contractors</li>
<ul>
<li>Address List</li>
<ul>
</ul>
To find the 'Address list', I might use an Xpath similar to this...
//ul[#class="main-menu"]//li[text()="Address List"]
Problem is, that would highlight all "Address List" items, and I do not want anything in the Employees list.
Keep in mind, this is only a sample menu, and I need to highlight more stuff all over the menu, both in sub-menus and on the main list, but I do not want to highlight anything in the Employees sub-menu, I want to exclude just those items in that list.
I've tried 'except' and 'not' but I guess I'm not getting how to use it or am putting it in the wrong context.
Try this on your actual html and see if it works:
//ul[#class="main-menu"]//
li[not(./text()="Employees")]
/following-sibling::ul/li[text()="Address List"]
Related
New to the coding game, and familiarizing myself with Sublime Text and its plugins on Windows10.
After much searching, I finally figured out that v 3 and 4 do not offer the inherent ctrl+shift+g macro to wrap with abbreviation, so I manually binded those keys to that command:
{"keys": ["ctrl+shift+g"], "command": "emmet_wrap_with_abbreviation"},
The problem now is I can't get $$ for multiple lines to sequence, i.e. 01-07. It instead outputs 01-01.
For example:
Typed Monday-Sunday on separate lines. Shif+right-click highlight days to tag and wrap individual lines. ctrl+shift+g to bring up emmet wrap abbreviation command line.
In line typed li.day-$$>span
Output:
<li class="day-01"><span>Monday</span></li>
<li class="day-01"><span>Tuesday</span></li>
<li class="day-01"><span>Wednesday</span></li>
<li class="day-01"><span>Thursday</span></li>
<li class="day-01"><span>Friday</span></li>
<li class="day-01"><span>Saturday</span></li>
<li class="day-01"><span>Sunday</span></li>
But should have been:
<li class="day-01"><span>Monday</span></li>
<li class="day-02"><span>Tuesday</span></li>
<li class="day-03"><span>Wednesday</span></li>
<li class="day-04"><span>Thursday</span></li>
<li class="day-05"><span>Friday</span></li>
<li class="day-06"><span>Saturday</span></li>
<li class="day-07"><span>Sunday</span></li>
as it was in a tutorial I was watching. Although, the tutorial was from 2014, so it would have been an older version of Sublime as well as Emmet, if that matters. Additionally, since the binded keys performed the function of bringing up the wrap abbreviation command line, I suspect a function in the line itself, but I'm not sure what or why.
It looks like you’ve used multiple cursors to select each line individually then wrapped it with abbreviation. Instead, you should select text you want to wrap as a single selection.
Also, when wrapping multiline text, you should mark repeated element with *. In your case, abbreviation should look like this: li.day-$$*>span
https://docs.emmet.io/actions/wrap-with-abbreviation/#wrapping-individual-lines
I use CKEditor within a template system where I use custom tags and then my PHP backend will replace the custom tags found in the HTML with data.
For example, on a tutorial I may have a standard set of instructions on how to do something, but certain examples require extra instructions. In a situation like that I would insert the <%Extra_Instructions%> custom tag into the html and then the php backend would replace that with the instructions for that page.
So in a list, I would do something like:
<ol>
<li>Step 1</li>
<li>Step 1</li>
<li>Step 1</li>
<%Extra_Instructions%>
<li>You are all done!</li>
</ol>
The problem is that CKeditor detects that the custom tag is not correct html and automatically moves it outside of the list. So the source would become:
<%Extra_Instructions%>
<ol>
<li>Step 1</li>
<li>Step 1</li>
<li>Step 1</li>
<%Extra_Instructions%>
<li>You are all done!</li>
</ol>
Is there a way to configure Ckeditor not to do this for certain tags?
If you want to place these tags in places like inside <ul>, then the only solution here is to use config.protectedSource. Matching fragments of data will be transformed into HTML comments during editing. This of course makes them invisible to a user, but it allows to keep them in places where other elements cannot be located. E.g. inside <ul> you can only have <li> so your custom tags can only be replaced by comments or <li>. Protected source gives you the former and the latter is a much more complicated option because you would like to make some constraints about editability of these tags.
Example usage of config.protectedSource:
config.protectedSource.push( /<%[\s\S]*?%>/g );
I'm trying to add Google Analytics click tracking events to li list items (active thumbnails) used in a responsive grid application, and can't get it working. I've researched here and in the Google developer forums without success. I'm sure there is something simple I'm doing wrong. I have the latest GA script code installed (page view analytics are working fine). Here is a code sample:
<ul>
<li data-type="link" data-url="http://www.dianagabaldon.com/books/outlander-series/" data-target="_self" >
</li>
<li data-thumbnail-path="outlander_files/thumbnails/outlanderbookseries1.png" ></li>
<li data-thumbnail-text >
<p class="largeLabel" >Diana Gabaldon - Outlander Series</p></li>
</ul>
Hope you can help. Feel free to suggest a better way of doing it.
Update: I'm still digging, and the GA code has been updated for Universal Analytics and looks like this:
<ul>
<li data-type="link" data-url="http://www.dianagabaldon.com/books/outlander-series/" data-target="_self" >
</li>
<li data-thumbnail-path="outlander_files/thumbnails/outlanderbookseries1.png" ></li>
<li data-thumbnail-text >
<p class="largeLabel" >Diana Gabaldon - Outlander Series</p></li>
</ul>
Update 2: I tried opening the outbound link target in a new page to see if a lack of callBack might be the problem. No success. Following are two views of the code, one with the contained inside the li with the outbound link, the other in a separate li with the same parent ul. Neither works. Does anyone know which syntax is correct? Thx.
Example 1: With href in it's own li:
<ul>
<li></li>
<li data-type="link" data-url="http://www.dianagabaldon.com/books/outlander-series/" data-target="_blank" ></li>
<li data-thumbnail-path="outlander_files/thumbnails/outlanderbookseries1.png" ></li>
<li data-thumbnail-text >
<p class="largeLabel" >Diana Gabaldon - Outlander Series</p></li>
</ul>
Example 2: With href inside outbound link li:
<ul>
<li data-type="link" data-url="http://www.starz.com/outlandercommunity/home.html" data-target="_blank" >
</li>
<li data-thumbnail-path="outlander_files/thumbnails/community1.png" ></li>
<li data-thumbnail-text >
<p class="largeLabel" >Starz: Outlander Community</p></li>
</ul>
The syntax you are using for the event tracking uses the classic GA syntax (_gaq.push), but if you are using Universal Analytics (assuming that is what you mean by using the "latest GA script code"), the syntax needs to be updated:
onClick="ga('send', 'event', 'GridLinks', 'Click', 'Outlander Clicks 1');"
I'm not familiar with Responsive Grid, but the likely explanation is that the call to ga only adds the event to a queue for asynchronous processing, and that the event is lost because the current document is immediately replaced afterwards (stopping the JavaScript execution for the current page). You would need to use a hit callback as described in the Google Analytics help, but I'm not sure how this would be integrated with Responsive Grid. Also note that there are a couple of other pitfalls you need to be aware of.
This is the current situation: There are several files and folders in a specific location.
Once you hover over a file or a folder, an icon appears then you can click on that icon and a menu will appear. From that menu a user can select any action(rename, move,etc). The problem is that the XPath which is provided by FirePath is broken whenever a new file/folder is created/added in the location.
This is the initial line of code which works fine until the XPath is broken:
webDriver.findElement(By.xpath("//*[#id='main_files_view']/ol/li[6]/ul/li[4]")).click();
Whenever a new item is added in the location, the index with value "6" can change to "7" (new position of the file) and the XPath generated is now slightly different:
webDriver.findElement(By.xpath("//*[#id='main_files_view']/ol/li[7]/ul/li[4]")).click();
How can I change that XPath and makes it robust so that no matter the number of items added/removed, the XPath will not break?
Below is the section of the HTML which is related to the XPath provided by FirePath.
When the XPath is provided, the last class is also highlighted.
<li class="storage_item document file_object even ui-draggable" data-thumb-translation="Translated" data-possible-actions="Rename Delete Share Move View" data-file-size="0 bytes" data-item-type="file" data-display-name="solids_A" data-name="solids_A.raas" data-id="bd48453c752043d98afb237b86ee88a3">
<a class="file_name" href="#/Item/Details?id=bd48453c752043d98afb237b86ee88a3&itemtype=File&tab=Default">
<img class="file_list_icon" width="16" height="16" src="https://api-staging.autodesk.com/content/gateway/2013.1.307595.626/z/Content/images/fileIcons/small/raas.png"/>
<div class="name_container">
<ul class="tools">
<li class="preview_trigger"/>
<li class="comment_balloon none has_tooltip" data-tooltip-contents="#comment_balloon_tooltip" data-comments="0">
<li class="categorize action has_tooltip" data-tooltip="Categories"/>
<li class="document_tools has_tooltip" data-tooltip="Actions"/>
</ul>
</li>
I am using Selenium 2.0, on Eclipse IDE.
If the data-name is unique, then you have
//*[#id='main_files_view']/ol/li[#data-name='solids_A.raas']/ul/li[contains(#class, 'document_tools')]
Css Selector is even better than XPath in this case:
#main_files_view li[data-name='solids_A.raas'] .document_tools
Try this:
By.XPath("//*[#id='main_files_view']/ol/li/ul/li[4]")
You do not have to define every index in an xpath and often if it's just one that change, removing that index will work.
In general you should avoid xpaths in your tests. Css selectors are faster (especially in IE) and more readable. If data-name is unique then this should work:
webDriver.findElement(By.cssSelector("#main_files_view li[data-name='solids_A.raas'] li.document_tools"));
If you really need an xpath the one provided by user1177636 will also do the job.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Is anything except LI's allowed in a UL?
I was doing something like that:
<ul>
<h3><a name="titlename">Title</a></h3>
<li>Text.</li>
<li>More text.</li>
<span>Click here to go to some place.</span>
</ul>
But i get warnings in visual studio:
Warning Validation (HTML5): Element 'h3' cannot be nested within element 'ul'.
Warning Validation (HTML5): Element 'span' cannot be nested within element эul'.
I googled and found that looks like it is not a problem to have another tags but <li> inside <ul>ю
But anyway may be some one have any opinions on that. Could it break something? do put you <h> tags or any another tags inside <ul>? What is your experience with that?
<ul> denotes an unordered list, while <li> denotes a list item that belongs to that unordered list - so it only really makes sense to have <li> elements within a <ul> element. If you want to give the unordered list a title, do it outside of the list (this would be the more 'normal' way), or within an <li> element that is inside the list.
<h3>My List Title</h3>
<ul>
<li>List items in here...</li>
</ul>
It is invalid if your <h3> is a child of the <ul>. You can only have it inside a <li> but not directly in a <ul>.
You can put inside ot <UL> tag only <LI>. And then in LI you can put what you want.
<ul>
<li><h3><a name="titlename">Title</a></h3></li>
<li>Text.</li>
<li>More text.</li>
<li><span>Click here to go to some place.</span></li>
</ul>
or
<h3><a name="titlename">Title</a></h3>
<ul>
<li>Text.</li>
<li>More text.</li>
</ul>
<span>Click here to go to some place.</span>
Yes, you can put anything you want inside of UL, but it's not by W3C standarts (you can see the validation errors) and nobody will guarantie you that in all browsers it will be displayed properly.