I am no coder, but know enough HTML to get the job done.
I have simple anchors for in-page linking and they work in every browser but Chrome.
What is the average joe explanation of what I can do to get them to work?
[a title="Important Safety Information" href="#isi"] Important Safety Information [/a]
[a id="ISI" name="ISI"][/a]
Page with anchor link: http://educationexchangehcp.ndei.org/novo/bolus-insulin-type-2-diabetes-education-novo-nordisk.aspx
Click on Important Safety Information on the right.
Please help! Thank you,
Brian
Your anchor is in all caps, but the link is in all lowercase. Change the <a id="ISI" name="ISI"></a> to <a id="ISI" name="isi"></a>. Also, if you're not using the ID tag for anything else, I'd just get rid of it. You don't need it for the anchor link to work.
HTML classes and ID names are case-sensitive. Change your code to [a title="Important Safety Information" href="#ISI"].
Related
I have hundreds of footnotes in scores of documents.
All are in HTML4 format. I have needed to update all the pages to HTML5.
When using a code checker for HTML5, I am informed that "NAME" as be deprecated and it I am getting warnings in to change the code.
I can't find a code example to resolve this. I am not looking to do anything fancy. I don't want to display the footnote by hovering the mouse over the call to the footnote. I just want to be able to click on a footnote number and get to it at the bottom of the page and then return! I don't see how that is done without "NAME."
Currently as an example, this is what a my code looks like. (I make have ten or more footnotes on any given page.
<P>This is in the regular text
<A NAME="sdfootnote1anc" HREF="#sdfootnote1sym"><SUP>1</SUP></A>></P>
AND it calls this at the bottom of the page.
<p><DIV ID="sdfootnote1">
<A NAME="sdfootnote1sym" HREF="#sdfootnote1anc">1</A> - Here I am explaining it before I go on after the break to the next footnote.</DIV><BR>
Change name to id
<A CLASS="sdfootnoteanc" id="sdfootnote1anc" HREF="#sdfootnote1sym">
<A CLASS="sdfootnotesym" id="sdfootnote1sym" HREF="#sdfootnote1anc">1</A>
Is it possible to make an <a href> link to the same page when your destination doesn't have an ID?
Jump to Topic 1
...
<!--destination is below-->
<h1 class="tab-title" data-editor-style="title" style="color:#444444">Topic 1</h1>
Sadly, the answer is no. You need an ID or at least a name, like CBroe mentioned in a comment of your question.
However, I found this here:
Today, all browsers recognize top as being the top of the page. If you
want the visitor to go to the very top of the page, the ID tag can be
left out and the A HREF link will still work.
A URL fragment identifier can only target an element with a matching ID, or a corresponding named anchor. You cannot link to arbitrary elements without IDs. (There was a proposal that would have allowed the use of CSS selectors as fragment identifiers, in which I was personally involved, but it never took off.)
The best you can do is to use JavaScript to select the element you want and give it an ID that is reserved for your hyperlink. If the elements matching this selector will change then you will additionally have to listen for such changes and handle them accordingly, but that's probably beyond the scope of this question.
I would like to know if it is possible to create a link to a specific span in someone else's page. For putting on a website or blog one might create for themselves, or even a local page one uses to put links to something interesting they found maybe.To be more clear, I want the link this way so that when someone clicks on the link, it goes to a specific location on the page, mostly for a long page where you want someone to go directly to the relevant information - when that part of the page doesn't have an anchor element you can make use of. I am using Wikipedia as an example, even though it might not be the best example, because I know Wiki uses it's own way of doing certain things. Say you wanted to link to the Wiki page "List of fallacies" and the span for the sublist titled "Red herring fallacies".
The page link is :
"https://en.wikipedia.org/wiki/List_of_fallacies"
Using Inspect Element, I got this for span :
<span class="mw-headline" id="Red_herring_fallacies">Red herring fallacies</span>
I tried to combine them like this :
<a href="https://en.wikipedia.org/wiki/List_of_fallacies<span class="mw-headline" id="Red_herring_fallacies">Red herring fallacies</span>">Red
herring logic fallacies list</a>
I am just wondering; am I a) doing it incorrectly for just using HTML, b) it can be done, but you have to use additional assets (CSS, JavaScript, etc), or c) it isn't possible to do at all?
I would like to do it using just HTML if possible, but if that is not possible, then I would appreciate it if someone can tell me how you might do it some other way - if it isn't impossible altogether. Thanks
Edit: My page is marked as a duplicate of answers to an earlier question, and from looking at the page it appears that this IS true. But I think my question heading itself was more clear to a beginner without much knowledge of advanced topics in creating webpages. Thanks for all of the help, and if the moderator believes my point is not relevant then please feel free to do whatever you do with duplicate questions.
you are missing a close "> just before the span started and you are missing the anchor in your href like this #Red_herring_fallacies, because span has that ID
<a href="https://en.wikipedia.org/wiki/List_of_fallacies#Red_herring_fallacies">
<span class="mw-headline" id="Red_herring_fallacies">Red herring fallacies</span>
Redherring logic fallacies list
</a>
The span has an ID. Use that as the parameter in your URL in the link.
Red herring logic fallacies list
To target an id you must add #theId at the end of your url.
The result will look ass follow:
<a href="https://en.wikipedia.org/wiki/List_of_fallacies#Red_herring_fallacies">
Red herring logic fallacies list
</a>
I am trying to simulate the click event of an anchor tag using watij on mac. I found the tag
<a name="myLink" href="" onClick=""></a>
My code is
Tag link = spec.jquery("a[name=myLink]").click();
But it does not seem to work. Please help.
Thanks & Regards,
Ankur Agrawal
You might try altering your reference to the link. Ex., referencing it by id or class, as shown here:
Hello
-
Tag link = spec.jquery("a.my_link").click();
Additionally, although I am not familiar with Watij, at this point in the code, are you positive that the <a> element has finished loading? You need to verify that all elements in the DOM have loaded before you simulate actions against them.
I am trying to search/select a link in a page that is underlined, while others are not. The source is something like this:
<a href="someurl1">
<b>
<u>Some ulined text</u>
</b>
<u></u>
</a>
<br>
Other link text
<br>
Another Link text
<br>
I tried something like
link = browser.link(:u?, true)
link.exists?
I get the following errors
TypeError: expected one of [String, Regexp], got true:TrueClass
from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/locators/element_locator.rb:152:in `check_type'
from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/locators/element_locator.rb:189:in `normalized_selector'
from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/locators/element_locator.rb:188:in `each'
from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/locators/element_locator.rb:188:in `normalized_selector'
from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/locators/element_locator.rb:76:in `find_first_by_multiple'
from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/locators/element_locator.rb:33:in `locate'
from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/elements/element.rb:260:in `locate'
from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/elements/element.rb:247:in `assert_exists'
from /usr/lib/ruby/gems/1.8/gems/watir-webdriver-0.2.4/lib/watir-webdriver/elements/element.rb:31:in `exist?'
Edit:
So I am actually using this for screen scraping rather than testing. That may explain the reasons why watir does not support this directly since CSS and other better practices make sense for testing and when you the HTML development and testing go hand in hand. Hoserver from a scraping perspective, the text formatting is what the user sees, and searching underlined, bold links etc. make sense for scraping.
I've never seen that kind of attribute used in a test case before. I also haven't seen any code support for it. You may have to roll your own. Here is an example borrowed from Zeljko
def hasUnderlined(browser)
s = false
browser.links.each do |l|
if l.html.downcase.match /\<u\>*\<\/u\>/
s = true
end
end
end
def getUnderlined(browser)
browser.links.each do |l|
if l.html.downcase.match /\<u\>*\<\/u\>/
return l
end
end
end
I don't think what you want is possible directly because the underline is not an attribute of the link tag, but a formatting tag that apples to just the text in the link.
However, in modern web pages, formatting is often controlled by a combination of CSS and attributes such as class names, which ARE something you could specify when identifying a link. So IMHO your best bet here might be to talk a little with your developers about how they are coding the site and see if they are perhaps open to increasing the testability of their code by using slightly more modern techniques for controlling what links are underlined, such as say using CSS and basing the underlining on a class name. (There's a lot of other good reasons to use CSS for controlling formatting instead of embedding it directly in the HTML, but unless your guys are fresh off the html-banana-boat so to speak, they should not need to be taught why using CSS is a good thing)
That would let you search for a link according to the class attribute that was being used to cause CSS to underline the text
If your developers are not open to such an approach to make their code more testable, then I think your only option is going to be to create your own ruby code for this and modify your copy of water (see #Dave's answer), and then be prepared to maintain that custom patch any time you update watir etc.
So, the only thing you know about a link is that it is underlined?
I thought this would do it (using the latest watir-webdriver gem):
browser.link.u.click
But I got this:
NoMethodError: undefined method `u' for #<Watir::Anchor:0x00000100cbb3c0>
Jari (watir-webdriver developer) said he thinks u tag is not in HTML spec.
By the way, this works:
browser.link.b.click
Jari suggested trying xpath, but I thought css selectors would be nicer to read. Here it is:
browser.element(:css => "a b u").click