How Can I Click This Link Using Watir? - hyperlink

I want to navigate a site using watir. I can't find nor focus on an element to click on it. It's the Next link on top right of this url:
Companies
How can I test that the link exists and can focus on it to click it?

The link HTML is:
<a id="view:_id1:_id258:pager6__Next__lnk" href="#" title="Go to next page:">Next</a>
The identifiable attributes seem to be the id (being careful of the auto-generated portions) or the title. The link could be located by either:
browser.link(title: 'Go to next page:') # using title
browser.link(id: /Next__lnk/) # using partial id
You can check if the link is available by checking if it is present:
browser.link(title: 'Go to next page:').present?
You can click with:
browser.link(title: 'Go to next page:').click

Related

Linking to an anchor/id located in another page

I'm trying trying to link to specific sections of the page below using the ID anchor tags. You can see they work when you're on this page: http://lastergroup.com/epe/epe19-240/dev/education.html, but when you navigate to other pages of this site, and click on any of the links on that dropdown menu, none work. What am I doing wrong? I have my IDs and links in place:
<div id="solarenergy">
Solar Energy
I found what was happening. After some research I learned that I have to use the anchor right before the div section I want to link to:
<a name="div1"></a>
Link

Why is activeClassName of gatsby's Link component not working for my anchor links?

So I am trying to create a one page site and I only want the navigation links to scroll to anchor links upon click. I am wondering though why the activeClassName does not work when I click those anchor links. What I noticed is that the active link that shows upon clicking the anchor links is the parent link.
I have already tried using partiallyActive={false} to the parent link but still nothing happens.
So this is my code:
<li>
<Link className={headerStyles.navItem} activeClassName={headerStyles.navItemActive} to="/" partiallyActive={false}>
Home
</Link>
</li>
<li>
<Link className={headerStyles.navItem} activeClassName={headerStyles.navItemActive} to="/#portfolio">Portfolio
</Link>
</li>
I expect the "Portfolio" link to be highlighted upon click but the highlight remains on the "Home" link. The url changes too but the activeClassName does not transfer from "Home" to "Portfolio". What could be going on here? Does activeClassName not work for anchor links?
As explained on the Link docs, you can't use a hash with Gatsby's Link:
Neither <Link> nor navigate can be used for in-route navigation with a hash or query parameter. If you need this behavior, you should either use an anchor tag or import the #reach/router package —which Gatsby already depends upon— to make use of its navigate function...
Also note that if you set partiallyActive to true on the "/#portfolio" link, then the "/" link will be highlighted given that "/#portfolio" also matches "/".

Create a link that jumps to a certain location on the page

How can I email or text a link that activates a jumplink to an anchor?
I want to show people my showreel by directing them to my website via link, but not make them have to scroll down to it.
Add an id attribute to any element on your page:
<div id="something"></div>
Then add a # to the url and the id value:
http://example.com/page.html#something

How to track URL source?

I have in my website "See More" link, what do I need to add to the link in order to see or count how many people using the "See More" link (with google analytics). This link is custom and unique per post. Is there any UTM parameter that I need to add?
You can add an event tracker to track when the link is clicked.
<a href='seemore.html' onclick="ga ('send', 'event', 'See more', 'click', this.href);">
This captures the link click as an event with the fully qualified url as the label. You can then see these events in the Events reports.
If the see more target is another page, you can use enhanced link attribution: https://support.google.com/analytics/answer/2558867?hl=en.

How to find link in a row in a table and then click on another link in same row

I am trying to click link in a row, which has another link that has name variable o.customer_id
Basically,I want to click a link "Action" which is in the same row as the link which has customer's id(which is variable)
I have tried using this but has not worked:
find(:xpath, link(have_content(o.customer_id)), :text => 'Action').click
Can someone please help?
Try adding parenthesis after the click to trigger it. I.e. click()
Also open the JavaScript console in your browser and make sure that find return a link element in your page.

Resources