selecting specific link from ng-repeat CSS using robot framework - css

Webpage opens one popup, in that popup I have a list of pets. like dog, cat, fish, etc. each element is a link, and defined as below in css. but all of them have same values for all of the attributes, like div class, ng-bind, ng-click, etc. only one difference is text. I am not getting how to select a specific value using this text.
Both of the images are attached for reference. you can check the CSS code as well as the application popup.
Application popup
Css Code
Please help me out....

In the below xpath example I'm assuming that this list is uniquely referenced using the #ng-repeat attribute and with that the following reference will become a unique one: //div[#ng-repeat='category in allCategory' and text() = 'Cow/Bull']

Partial matching of the text with xpath, just a little modification to the first answer.
//div[contains(text(),'Cow/Bull') and #ng-repeat="category in allCategory"]

Related

GTM - CSS Element

I'm wanting to create a variable to grab the username from a landing page (assuming it's possible). In my attached examples, I'd like to grab the text "Landing_page_test".
I'm just learning CSS so I'm not able to single out just that text.
Any thoughts/suggestions would be much appreciated! enter image description here
Console
Elements Pane of Landing Page
document.querySelector returns an element, not the text. Add .innerText
Try it out on this page: document.querySelector("a.question-hyperlink").innerText to get the name of the question.
But you probably don't want to do it as custom html tag. You probably want to do it on click. in that case, you have {{Clicked Element}} variable in GTM, of which you can also get .innerText, or get its .parentElement and further navigate DOM from the clicked element as you wish and get whatever you need.
Here's the html of the Location & Date/Time text blocks
Text Block

Simple HTML Dom get href that begins with

I am using Simple HTML Dom to extract information from a remote source. I would like to get all href links that contain a particular piece of text (not all on a page). I have tried
->find('a[href*="/place"]')
and
->find('a[href="/place"*]')
and
->find('a[href="/place*"]')
but this returns empty results.
The href I am trying to get must begin with the text "/place".
Any suggestions?
Thanks
Match elements that have the specified attribute and it starts with a certain value, use [attribute^=value].
->find('a[href^="/place"]')
Ref: http://simplehtmldom.sourceforge.net/manual.htm#frag_find_attr
I do not now this app, however did you try using the asterisk like so ?
>find('a[href="/place*"]')

#div:normal #div:hover #div:SELECTED?

On the "services" and "company" pages I have a right sidebar list. This is being included with PHP. So far I have a CSS class for normal and a CSS class for when you hover each item in the list. I want to have a new class for when each list item is selected. So for example in services, the user clicks on "family planning" and when they get to the family planning page....the family planning list item has a grey background. Is this possible?
http://beulahprint.ie/index.php
Cheers,
Colm
Nothing in CSS will let you match an element based on it's href attribute resolving to the current URL.
Add a class to the menu item (or the body element) server side based on the page, then use a write a selector to match that.
There are a few ways to accomplish this but you'll need a little bit of code. It works like follows:
On your page you should somehow declare which page it is (by using a querystring or session)
Then you should parse this value and write out the class name of the menu dynamiclly.
Yes it is possible, when rendering the sidebar/menu, check if they are in a specific page/namespace and add a class to it which has grey background.
The general design people use for such scenarios is to place all items related to one menu item in one namespace.
like all admin items will be under */admin/*, so that when rendering the menu, they will check the url and add the class to it.

How to use seleniumRC in Junit framework on dynamically changing elementids

I am trying to automate a work flow process .In this,I need to click on a link positioned in any of the rows of table.Thing is all links available in all rows have same element ID and in the source code I have a java script like " ("Element ID" # Onclick..java script****:).....SO here after clicking it is connecting one form to another form by inputting some value in java script code and also one value in java script dynamically changes.How do I click on that link now?Is there any solution using xpath or so...to exactly click on that link based on CSS classID or so...Please help me out..Main problem is...all links in rows have same element ID and dynamically changing java script .
I am trying to use selenium.focus() and selenium.clickAndwait().But these are helpless.as it is not able to identify link ID only.
The best way to do this would be with xpath.
Something like //*[#onclick='javascript'] will work but this can make the tests extremely flaky because if the inline javascript changes or if its removed in preference of addEventListener to the element.
something like //*[#class='cssClass'] will work. I think that you will need to speak to the developers and ask them to help make it more testable.

Testing ASP.NET sites using master pages with Selenium

What is a good approach to avoiding Selenium tests being broken when dealing with the changing "Name" and "Id" attributes of a control that is rendered on a ASP.NET page using a master page? I want to avoid changing my tests when ASP.NET renders the web page's controls with different DOM identifiers.
http://www.stevetrefethen.com/blog/AutomatedTestingOfASPNETWebApplicationsUsingSelenium.aspx
Selenium
solves this problem using XPATH and
providing the ability to locate
controls based on XPATH expressions,
alleviating the need to hard code HTML
tag structure into a test script. For
example, the ASP.NET runtime may
render ID attributes that look like:
id="ctl00_cphContents_gridMaint_DataGrid"
Finding this control using an XPATH
expression can be simplified to
something like this:
table[contains(#id, "gridMaint")]
In the event the nesting of the
DataGrid changes the script will
continue to function properly as long
as table's ID contains the text
"gridMaint".
Another option is to use CSS locators. They're normally less fragile than XPath. For example, to target a div with a class of .myDiv you can use the locator "css=.myDiv". If the specified element has other classes the CSS locator will still work, although the XPath equivalent would change from "//div[#class='myDiv']" to "//div[contains(#class, 'myDiv']". Also, CSS locators tend to be faster than XPath across browsers.

Resources