Skip to content

Update elementfinder.py to allow of use scLocator - #352

Merged
emanlove merged 1 commit into
robotframework:masterfrom
IlfirinPL:patch-1
Feb 11, 2015
Merged

emanlove merged 1 commit into
robotframework:masterfrom
IlfirinPL:patch-1

Conversation

@IlfirinPL

Copy link
Copy Markdown
Contributor

Change contains new strategies scLocator and new method _find_by_sc_locator, solution is using build into smart client function isc.AutoTest.getElement

Change contains new strategies scLocator and new method _find_by_sc_locator, solution is using build into smart client function isc.AutoTest.getElement

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of questions. One, you use a double backslash "" when in all your references I see a double forward slash "//". For example, from here I see

//ListGrid[ID='filterGrid']
 //DynamicForm[ID="autoTestForm"]/item[name=textField||title=textField||value=test||index=0||Class=TextItem]/element 

and from codecentric

//DynamicForm[ID="doSearchForm"]/item[name=mainRegisterBox]/element
//Button[ID="searchPerson"]/
//ListGrid[ID="hitList"].0.0

Second, you also are replacing within the given locator what seems to be a leading single quote. That makes me assume that you are expecting the user to write a locator like these

scLocator='ListGrid[ID='filterGrid']'
scLocator='//ListGrid[ID='filterGrid']'

Again I am not familiar with SmartClient and SmartGWT but the general usage for locators within Selenium2Library has been without the quotes. For example

Good
----
id=my element id
id=this-element

Not-used
--------
id='quoted-string'
id='no used locator'

I know myself I forget this and added quotes ever once in a while. If there is a possibility of having a double space in the locator I can see the need to have the sytax support quoted locators. But again in general that is not how they are used elsewhere.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think they are just handling single quotation marks embedded in a string using single quotes as the start and termination characters so the JS statement is syntactically OK. jQuery selector is very similar and does the same thing. The double backslash is to escape the backslash which is a special char in Python.
Leaning toothpick syndrome!
Without replace (bad):
return isc.AutoTest.getElement('//ListGrid[ID='filterGrid']')
With replace (good):
return isc.AutoTest.getElement('//ListGrid[ID=\'filterGrid\']')

@IlfirinPL

Copy link
Copy Markdown
Contributor Author

I am using currently provided solution and its using locators that could be found using selenium ide with extensions for SmartClient
This replacement is used to mask ' if used in locator during execution ' will execution work as '
example use is like below is working properly, its not required to have quotes.
Wait Until Page Contains Element scLocator=//SectionStack[ID="eventSectionStack"]/section[Class=SectionHeader||index=0||length=1||classIndex=0||classLength=1||roleIndex=0||roleLength=1||title=Event%20Summary||scRole=heading||name=EventSection]/

@emanlove

Copy link
Copy Markdown
Member

Ok, I read that wrong. You are un-escaping quotes, ', making them simply quotes, '. Just checking. Do you have any documentation you would like to have added so users will know how to use this locator? And possible any public facing websites that we can run sanity checks on the code base in case any changes occur near this?

@IlfirinPL

Copy link
Copy Markdown
Contributor Author

About documentation i would like to add new row in strategy table on Selenium2Library.html
scLocator |
scLocator=//TreeGrid[ID="isc_SideNavTree_0"]/body/row[nodeTitle=Smart%20GWT%20Showcase||0]/col[fieldName=nodeTitle||0] | should match scLocator selector

Here you can find showcase of smartclient
http://www.smartclient.com/smartgwt/showcase/#featured_complete_app

but locators provided by SC are really long and its typical

emanlove added a commit that referenced this pull request Feb 11, 2015
Update elementfinder.py to allow of use scLocator
@emanlove
emanlove merged commit 494f32b into robotframework:master Feb 11, 2015
@emanlove

Copy link
Copy Markdown
Member

Ok, I'll add some documentation within a separate pull request.

@IlfirinPL
IlfirinPL deleted the patch-1 branch February 11, 2015 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants