Skip to content

SmartClient and SmartGWT #333

Closed
Closed

Description

@IlfirinPL

SmartClient and SmartGWT its not possible to use locator like 'scLocator'
Maybe its possible to port keyword "Add Location Strategy" from SeleniumLibrary or extent this this type of strategy to common available strategy. Other solution to allow import of user-extensions.js/user-extensions-ide.js.

Below some links related to this topic

http://www.smartclient.com/smartgwtee-latest/javadoc/com/smartgwt/client/docs/UsingSelenium.html
MarkusBernhardt/robotframework-selenium2library-java#1
https://blog.codecentric.de/en/2010/12/testing-smartgwt-applications-with-selenium-and-robot-framework/

Activity

  1. emanlove commented on Oct 1, 2014

    @emanlove
    Member

    Looking at the codecentric article it looks as if the locators are simply xpath locators. Is there anything unique with SmartClient and SmartGWT elements? Does one use javascript to find those elements?

  2. ombre42 commented on Oct 2, 2014

    @ombre42
    Contributor

    I think they just look like XPath. See the JavaScript implementation for Selenium 1.

  3. IlfirinPL commented on Oct 2, 2014

    @IlfirinPL
    ContributorAuthor

    I have example like recorded from selenium IDE
    type |scLocator=//ListGrid[ID="ChainList"]/filterEditor/editRowForm/item[name=name||title=Chain%20Name||value=test||index=0||Class=TextItem]/element | test

    used in robot like
    Wait Until Page Contains Element xpath=//ListGrid[ID="ChainList"]/filterEditor/editRowForm/item[name=name||title=Chain%20Name||value=test||index=0||Class=TextItem]/element
    Input Text xpath=//ListGrid[ID="ChainList"]/filterEditor/editRowForm/item[name=name||title=Chain%20Name||value=test||index=0||Class=TextItem]/element test

    rise following error

    InvalidSelectorException: Message: u'The given selector //ListGrid[ID="ChainList"]/filterEditor/editRowForm/item[name=name||title=Chain%20Name||value=test||index=0||Class=TextItem]/element is either invalid or does not result in a WebElement. The following error occurred:\nInvalidSelectorError: Unable to locate an element with the xpath expression //ListGrid[ID="ChainList"]/filterEditor/editRowForm/item[name=name||title=Chain%20Name||value=test||index=0||Class=TextItem]/element because of the following error:\nSyntaxError: The expression is not a legal expression.' ; Stacktrace:
    at FirefoxDriver.annotateInvalidSelectorError_ (file:///d:/temp/tmpyeww35/webdriver-py-profilecopy/extensions/fxdriver@googlecode.com/components/driver-component.js:9592:5)
    at FirefoxDriver.prototype.findElementsInternal_ (file:///d:/temp/tmpyeww35/webdriver-py-profilecopy/extensions/fxdriver@googlecode.com/components/driver-component.js:9650:5)
    at FirefoxDriver.prototype.findElements (file:///d:/temp/tmpyeww35/webdriver-py-profilecopy/extensions/fxdriver@googlecode.com/components/driver-component.js:9654:3)
    at DelayedCommand.prototype.executeInternal_/h (file:///d:/temp/tmpyeww35/webdriver-py-profilecopy/extensions/fxdriver@googlecode.com/components/command-processor.js:11612:16)
    at DelayedCommand.prototype.executeInternal_ (file:///d:/temp/tmpyeww35/webdriver-py-profilecopy/extensions/fxdriver@googlecode.com/components/command-processor.js:11617:7)
    at DelayedCommand.prototype.execute/< (file:///d:/temp/tmpyeww35/webdriver-py-profilecopy/extensions/fxdriver@googlecode.com/components/command-processor.js:11559:5)

  4. ombre42 commented on Oct 2, 2014

    @ombre42
    Contributor

    This isn't the first time adding a custom strategy has come up, but I can't remember where it was discussed. Adding custom strategies would be a nice feature to have, and I do not think it would be very hard to implement.
    @IlfirinPL I would be able to recommend a workaround until adding custom strategies is supported, but I cannot find the production code used for the scLocator - closed source maybe?
    Custom By for Java WebDriver
    I cannot find the source for this. A prototype can be found in the forums.

  5. IlfirinPL commented on Oct 3, 2014

    @IlfirinPL
    ContributorAuthor

    There are sources http://smartclient.com/builds for smart client but only included driver as jar

    below sources for isomorphic-webdriver with Class ByScLocator
    http://www.speedyshare.com/qBABJ/isomorphic-webdriver.src.zip

  6. emanlove commented on Oct 4, 2014

    @emanlove
    Member

    In the back of my head I see using something like Zope interfaces (named "Zope" because it came from Zope but they are not unique to or require Zope to be used). Basically giving people a plug and play interface to add their own locators. Probably overkill but still a thought...

  7. ombre42 commented on Oct 5, 2014

    @ombre42
    Contributor

    I looked at how the Java bindings handle this and how elementfinder works. In the Java bindings, a custom By receives a search context, which could be either a WebElement or WebDriver. The jQuery, your angularJS locators receive nothing but the driver. The filtering is done the same for every locator. For a user locator, S2L should take care of that (and it should probably be refactored if there's no scenario where filtering won't be done).
    I'm thinking
    def add_locator_strategy(prefix, method) where method is a callable that takes one argument. That argument may be a webdriver instance or webelement instance (future proofing for the changes you mentioned in the user group). The callable must return a list of webelements.
    Perhaps I am failing to see the complexity you see?

  8. IlfirinPL commented on Oct 6, 2014

    @IlfirinPL
    ContributorAuthor

    I think this adding locator strategy should be sufficient, other part is rising error when element is not found for some reason method like "Wait Until Page Contains Element " shouldn’t rise those type of errors

  9. ombre42 commented on Oct 6, 2014

    @ombre42
    Contributor

    Wait Until Page Contains Element only raises an error on timeout. If there is an unexpected error, though, it is not caught and will bubble up and cause the wait keyword to fail.
    After mulling over, I don't think only having a single callable is good. It leads to boiler plate code checking if the search context is a web element or a driver. Would be cleaner if the user code has separate methods like find_elements and find_elements_from_webelement. I think we should define an API like RF does for things like listeners and provide an abstract class, but not require it to be used. In the abstract class we could provide a method to make polling with timeout easy to do - see #337.

  10. IlfirinPL commented on Oct 8, 2014

    @IlfirinPL
    ContributorAuthor

    I don`t think we should split method into two based on what we search for WebElement or WebDriver.
    As end user I want to specify xpath and it should be search both areas.

  11. IlfirinPL commented on Nov 21, 2014

    @IlfirinPL
    ContributorAuthor

    Maybe its possible to implement in python similar to code below
    "selenium.setExtensionJs("src/main/resources/user-extensions.js");"

    more example code
    protected static DefaultSelenium selenium;

    @BeforeClass
    public static void setUp() throws Exception {
        selenium = new DefaultSelenium("localhost", 4444, "*firefox", getBaseUrl());
        selenium.setExtensionJs("src/main/resources/user-extensions.js");
        selenium.start();
        selenium.windowMaximize();
        BaseSeleniumChecks.selenium = selenium;
    }
    
  12. IlfirinPL commented on Dec 5, 2014

    @IlfirinPL
    ContributorAuthor

    I have method that would have to be added to elementfinder.py to allow support of scLocator.

    it required 2 modification add next strategy
    in method init
    'scLocator': self._find_by_sc_locator,

    and add method itself

    def _find_by_sc_locator(self, browser, criteria, tag, constraints):
    js = "return isc.AutoTest.getElement('%s')" % criteria.replace("'", "'")
    return self._filter_elements(
    [browser.execute_script(js)],
    tag, constraints)

  13. IlfirinPL commented on Dec 5, 2014

    @IlfirinPL
    ContributorAuthor

    pull request 352
    #352

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions