How to test all links on a page with Selemiun IDE - selenium-ide

I'm new at using Selenium and I'm surprised this question hasn't been asked before but, does anymore know how I can check all the links on a page to make sure none of them are broken?

If you want to check all the links on a page using selenium if so the first you need to click and you need to record first. And you can check with assertLocation. It was broken or not.But I want to give you some advice if you have many tests if so please use webdriver. Because IDE have many limitation.
You can check this article for webdriver Finding the broken links in a webpage using Selenium

First you need to fetch all the links.
public static void allLinks(WebDriver driver)
{
List<WebElement> links =driver.findElements(By.tagName("a"));
for(int i =0;i<links.size();i++)
{
System.out.println(links.get(i).getText());
}
}
Here I am just printing all the hyper links by using tag name as all hyperlinks have this anchor tag <a>.
Hope this helps.

Related

How to remove More help link from moodle 2.8 help popup?

I want to remove More help link from moodle 2.8 help pop up.
I am attaching screenshot:
After click on this link, open docs.moodle.org/28/en/mod/lesson/view page
Got solution from moodle forum but not working for me.its for moodle 2.7
There is no option to remove the help link without modifying Moodle code. However you could either:
Define $CFG->docroot in your config.php to customise the URLs, or
Use CSS to hide the link.
If modifying core is not an issue, the easiest way is to modify the function get_formatted_help_string so that it never looks for the language string ending in _link. You would remove the following block:
$helplink = $identifier . '_link';
if ($sm->string_exists($helplink, $component)) { // Link to further info in Moodle docs.
...
}

Wicket AjaxLink generates no JavaScript

I started experimenting with Wicket AJAX functionality and wanted to implement an AjaxLink.
This is the associated markup/java-code:
<a wicket:id="testlink"></a>
---
AjaxLink<Component> link = new AjaxLink<Component>("testlink") {
#Override
public void onClick(AjaxRequestTarget target) {
System.out.println("called");
}
};
add(link);
But the onClick-method is never called, I guess because the generated HTML looks like this:
<a wicket:id="testlink" id="testlink7" href="javascript:;"></a>
Any ideas on what I am doing wrong?
This href="javascript:;" works because Wicket 6 uses JavaScript Event registration. Look at your webpage in some browser dev tool like in firefox. Point the inspector to the link and read it's id, then go the the head section and expand one of the <script type= text/javascript></script> tags. There you should find the id of the link and see that there is an line where a click event is attached to the id of the link. The URL there is executed when you click the link.
Thanks Robert for clarifying the ajax mechanisms of Wicket 6 - I'm rather new to this topic and the insights you gave me helped solve the problem.
Actually it was caused by some jQuery inconsistency I still haven't fully untangled, apparently coworkers used different jQuery-versions within different of our Wicket modules and somehow Wicket used not the one it was shipped with but a wrong one when trying to attach the event listener to the component.
When removing the unneccessary old jQuery libraries Wicket started to work fine - now I just have to get the components depending on the other jQuery libraries working again, but thats a different story :)
In my situation, I removed the following onload on body tag and the AjaxLink onclick function worked again.
<body onLoad="MM_preloadImages('template-image/searchbto.png');">

How to find Itune software is installed in a client browser side?

I have a anchor tag with the url "itms://itunes.apple.com/us/app/movietickets-com-showtimes/id402114309?mt=8".If the client system doen't have the Itune software, then the browser is not opening the page.
Is there any way to know the whether the user installed Itune software or not.
Thanks in advance.
Note:
If you go to
https://itunes.apple.com/us/app/movietickets-com-showtimes/id402114309?mt=8
Here you can find or inspect "view in itune" button.There you can see
some javascript to detect that.But i dont know what there are doing!
Apple already has code to detect if iTunes is installed, you can find their code here: http://ax.itunes.apple.com/detection/itmsCheck.js
Finally i got a solution,
From the following site https://itunes.apple.com/us/app/movietickets.com-showtimes/id402114309?mt=8
You need to take two js files. (It contains some extra javascript and jquery - you can remove those if you know that it is no longer needed)
https://itunes.apple.com/htmlResources/99EF/web-storefront-base.js
https://itunes.apple.com/htmlResources/99EF/web-storefront-preview.js
And you need to add the below code to your page html,
""
Finally, Whenever you want to check the plugin, just call
if (its.detect.itunesDetected())
{
//Your code if plugin installed
}
else
{
//Your code if plugin not installed
}

How can I access which files the user currently has open from an eclipse plugin?

I'm very new to eclipse plugin development, and frankly to eclipse itself. I am trying to find a way to access a list of which files are currently being worked on by the user, and possibly even more specifically, what part of these files (which class, method, block of code, etc.).
I am thinking that I would like to have the plugin grab information on which files are currently open in the tabs, and then go from there, but I can't even figure out how to do this. I've been searching the eclipse documentation at help.eclipse.org, but I still haven't found anything useful for what I want to do. Does anyone have any ideas?
Try the following code:
IWorkbenchPage[] pages = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getPages();
for (IWorkbenchPage page : pages) {
IEditorReference[] references = page.getEditorReferences();
for (IEditorReference reference : references) {
IEditorInput input = reference.getEditorInput();
}
}
You should be able to walk your way from the workbench to a workbench page (IWorkbenchPage), which as a findEditors method.

Listener on open file in Eclipse

I am currently working on a Eclipse Plugin, where I need to make an action, when a person opens a file with certain properties. However I'm not sure on how to set a listener, I have been looking into the IWorkspace and IResource API, but I can't find the simple API call saying "AddListenerToOnOpenFile".
The file is expected to be opened in the package explorer view.
Use the answer supplied by #MarttiKäärik to find out when editors are open. Then you can use the IEditorInput to see if it is an IResource you care about.
if (part instanceof IEditorPart) {
IEditorPart editor = (IEditorPart) part;
IResource resource = editor.getEditorInput().getAdapter(IResource.class);
// ...
}
Question already answered, so only to make it a bit more complete...
You don't necessarily have to implement a view or action (as described in the question linked to by Martti Käärik in a comment) to get a window for your listener. Call to PlatformUI.getWorkbench().get...() can be used as well. See the older, probably duplicate, question called just Eclipse Plugin.
BTW Eclipse Wiki FAQ page contains a good description of the ways how to obtain the current workbench window and possible "gotchas".
Moreover, you can even listen for newly opened windows if there is a need:
PlatformUI.getWorkbench().addWindowListener(listener);