Find and take value of href using protractor - protractor

enter image description here
I had search and read many guides but it doesnot work. Could someone please help me? I want to get the href value like in the image. Thanks for reading my post.

You can use getAttribute() method to get the value of any property available in the webelement. In your case you need to find the respective element and can use below code to get the href value,
element(by.css("a")).getAttribute("href").then(function(hrefValue){
console.log("href value",hrefValue);
})

Related

how to get the already selected value of dropdown protractor

I have a select tag with some options under it . I select one value out of those along with other field values and move to next page. Once I return to previous page I want to check whether the dropdown value is same as that I selected. How can I get the already selected value using protractor. Can someone please help.
Following #Grasshopper's comment, I read this, and the following worked for me:
expect(element(by.xxxxxx('xxxxxxx')).$('option:checked').getText()).toEqual('xxxxxx')
var dropdownval=element(by.xpath/css("Xpathofdropdown/cssofdropdown")).element(by.css('option:checked')).getText();
console.log(dropdownval);
The following code helps me to resolve the issue,now the variable contains the value of the dropdown selected
var dropdownval=element(by.xpath("XpathOfDropdown")).element(by.css('option:checked')).getText();
console.log(dropdownval);
First select the input, then select the option using css, with the option:selected tag:
var selected = element(by.css('#ID_OF_THE_SELECT option:selected'))

calculation with select option value using javascript

I have query related to javascript that we call a function where is id in select option tag. So can we use this id for calculation in other function? how to get this id? If yes then how? If no then please give me some other idea..
How to read this id?
Give me result soon.
Use .val(), see this jsfiddle example. Here i'm using .change() you probably want to use .submit for this.

org.eclipse.ui.dialogs.ListSelectionDialog input options?

i try to display a dialog for selection the fields of a source.
i like to use the ListSelectionDialog, but i'm not sure what to use for the input parameter.
all the examples in the web uses the
ResourcesPlugin.getWorkspace().getRoot()
as input and yeah, all the projects are displayed.
but i have a list of Fields (IField[]) that i want to show for selection.
the constructor of ListSelectionDialog accept the parameter, but the dialog shows nothing... :(
does anybody has an idea?
thanks a lot!
Sven
I don't think using BaseWorkbenchContentProvider is right. Try ArrayContentProvider.
So something like:
new ListSelectionDialog(shell, fields, new ArrayContentProvider(), labelProvider, msg);

Need to print out all links on a sidebar in selenium (xpath?)

I need to find any extra links and print them out. I started by doing:
get_xpath_count('//li/a')
and comparing it to the size of an array that holds the name of all the links for the sidebar. When the count is too high/low, I need to print out all the extra/missing links. I would like to make a list of the names so I can compare it to the array. I've tried a few things like get_text('//li/a'), which returns the name of the first. get_text('//li/a[1]) does the same, but any other index returns nothing.
Any ideas? Also, I need the name that's displayed on the link, not the actual href.
Edit* Also, i'm pretty new to selenium and Xpath. Please let me know if there's info I let out that is needed, or just any suggestions towards thew way I'm going about this.
I have been able to get this to work using CSS element locators. Since I use CSS selectors far more often than Xpath, I find it easier to always use them with Selenium as well.
$selenium->get_text("css=li a:nth-child(1)")
$selenium->get_text("css=li a:nth-child(2)")
$selenium->get_text("css=li a:nth-child(...)")
$selenium->get_text("css=li a:nth-child(n)")
Use:
(//li/a)[$someNumber]
this will get you the text of $someNumber-th //li/a in the XML document.
In order to know what values to use to substitute the $someNumber with, you need to know the total count of these elements:
count(//li/a)
This is in JAVA. You can use the same concept in perl
int totCountInPage=selenium.getXpathCount(//li/a);
for(int count=1;count<=totCountInPage;count++)
System.out.println(selenium.getText("xpath=//li[count]/a"));
This should print text inside the anchor links under all li tag.

Prototype js get element with certain value

I am scraping some data and I want to get the the value of an element after a specific tag with value.
It's a bold tag with value 'Types:'.
<b>Types:</b>
Once I get to that element I can use Prototype's Element.next() to get the data I want.
How exactly do I do this?
I have been fiddling with $$ but can't seem to get it right..
Thank you!
Return the first b element with value "Types:":
$$('b').find(function(n){return n.innerHTML=="Types:"})