Relative path to @objects

87 views
Skip to first unread message

blokhi...@gmail.com

unread,
Aug 10, 2015, 10:53:30 AM8/10/15
to Galen Framework
Hi, I`m new to Galen.
I want to use relative path to my @objects like in selenium:
findElement(By.xpath"").findElement(By.xpath"")

I notices that Galen has "compomemt spec" which lets using .spec in .spec
But i`m not sure that it inherits the behaviour I need


Ivan Shubin

unread,
Aug 10, 2015, 11:05:48 AM8/10/15
to Galen Framework
In Galen you can nest object under each other and that does exactly what you want. Please check the documentation http://galenframework.com/docs/reference-galen-spec-language-guide/#Objectdefinition
In your spec you will have to reference to the "input" object by using complete path: "search-panel.input"

Message has been deleted

blokhi...@gmail.com

unread,
Sep 16, 2015, 9:38:45 AM9/16/15
to Galen Framework
Hi again!


I have another problem with relative path to objects
This is my object definition

c21                     css       div[data-gtm-module-type-id='C21']
content css div.rco-ui-cta-content
contentArea-* css p

And when I try to use it I have unexpected behaviour

@for [${getRangeWithoutLast("c21.content.contentArea-#")}] as index
c21.content.contentArea-${index}:
above c21.content.contentArea-${index+1}

On this cycle Galen doesn`t take required element on the page. It takes the first available tag <p> which is not in c21.content(div.rco-ui-cta-content). And my test crashes
https://nimbus.everhelper.me/client/notes/share/287561/76qKl7A3i0pQvHRdJK8HxpD0Ntm2huqk/   - example

It doesn`t occur every time, and sometimes Galen find the element is needed
Unfortunately, I couldn`t track when it happend

Ivan Shubin

unread,
Sep 16, 2015, 9:56:06 AM9/16/15
to Galen Framework
Ok, so you basically use your own js function "getRangeWithoutLast". Are you sure the problem is not in it?
If I understand correctly you want to iterate over all elements without last one. Why don't you do it like this?

@forEach [c21.content.contentArea-#] as item, next as nextItem
    ${item}:
        above ${nextItem}


blokhi...@gmail.com

unread,
Sep 16, 2015, 10:18:33 AM9/16/15
to Galen Framework
In this case I can use forEach.
But in other cases I have range from 4 till end without two last elements (I don`t know their quantity) or I use ${index} in other checks. Or of I have only two elements it will not check it, but I have other checks in this loop

And even I try to use c21.content.contentArea-1: it found the first occurrence of an element on the page

My getRangeWithoutLast function: 
this.getRangeWithoutLast = function(pattern) {
var size = findAll(pattern).length - 1;
var parameter = "1 " + "- " + size;
return parameter;
};

Ivan Shubin

unread,
Sep 16, 2015, 10:28:41 AM9/16/15
to Galen Framework
I don't see anything wrong in your function. Perhaps there is something wrong with objects matching. If you say that it happens randomly then my only guess would be that the page is dynamic and it builds up the content  too slow. What if you wait for all the elements first and then run layout check? You could simply try a hardcoded sleep of few seconds for now.

blokhi...@gmail.com

unread,
Sep 16, 2015, 10:48:04 AM9/16/15
to Galen Framework
I've thought about it and even tried, but id didnt help me. I`m not sure that it happens randomly but I can`t track it.
And I noticed that if I use whole locator div[data-gtm-module-type-id='C21'] div.rco-ui-cta-content p  for contentArea-* css it works correctly
Reply all
Reply to author
Forward
0 new messages