Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    WebElement.sendKeys to AutoFitTextAreaItem loses characters when text wraps

    I am using SmartClientFirefoxDriver. I create a WebElement using this code

    Code:
    By scByLocator = ByScLocator.scLocator(“//DynamicForm[ID='CG$RECORDER$CONCLUDE$Notes']/item[title=isc_NoteTextArea_0||index=0||Class=AutoFitTextAreaItem]/element”);
    WebElement webElement = smartClientRemoteWebDriver.findElement(scByLocator);
    webElement.sendKeys(“enough characters to cause AutoFitTextAreaItem to wrap”);
    This causes loss of characters that have been sent to the NoteTextArea where the wrapping occurred.

    #2
    A few observations:
    - You should be calling findElement() on the SmartClientFirefoxDriver instance, not on the RemoteWebDriver instance inside the implementation. We're assuming you may be doing this because you're calling findElement() on a variable named smartClientRemoteWebDriver. Right now, the outer API is just a pass-through, but there's no guarantee it will always remain that way.
    - Further note that sendKeys() should also be called on SmartClientWebDriver to allow our custom code to run. The WebElement.sendKeys() method is not something we implement or override. Please review the SmartClientWebDriver APIs and observe which functions are present - these are the APIs that should be used. There are also "type" and "keyDown/keyPress/keyUp" methods.
    - When you say "this causes loss of characters," do you mean that part of the single sentence itself is lost, or that something previously typed into the field is lost? If the first, what is lost - everthing before the wrap?

    Comment


      #3
      Originally posted by Isomorphic View Post
      You should be calling findElement() on the SmartClientFirefoxDriver instance
      I’m sorry my code example was not clear as it should have been. The full example is:

      Code:
      private SmartClientWebDriver smartClientWebDriver = new SmartClientFirefoxDriver();
      smartClientWebDriver.setBaseUrl("");
      smartClientWebDriver.get("someUrl.com");
      By scByLocator = ByScLocator.scLocator(“//DynamicForm[ID='CG$RECORDER$CONCLUDE$Notes']/item[title=isc_NoteTextArea_0||index=0||Class=AutoFitTextAreaItem]/element”);
      WebElement webElement = smartClientWebDriver.findElement(scByLocator);
      webElement.sendKeys(“enough characters to cause AutoFitTextAreaItem to wrap”);
      Originally posted by Isomorphic View Post
      Further note that sendKeys() should also be called on SmartClientWebDriver to allow our custom code to run
      As you can see in the code above I’m assigning what was created by new SmartClientFirefoxDriver() to SmartClientWebDriver smartClientWebDriver. Is there another way I should be doing this to make sure I’m accessing the correct SmartClientWebDriver methods?

      Originally posted by Isomorphic View Post
      When you say "this causes loss of characters," do you mean that part of the single sentence itself is lost, or that something previously typed into the field is lost? If the first, what is lost - everthing before the wrap?
      Part of the single sentence is lost. In my tests I first clear the AutoFitTextAreaItem and then I send a single string. The loss of characters is around the point of text wrapping.

      I tried a variety of ways to work around this problem including only sending a single word at a time. Finally, the only thing that works is sending a single character at a time with sendkeys(). This is OK but it makes the test run 3-5X slower.

      Comment


        #4
        Originally posted by dbscott525 View Post
        As you can see in the code above I’m assigning what was created by new SmartClientFirefoxDriver() to SmartClientWebDriver smartClientWebDriver. Is there another way I should be doing this to make sure I’m accessing the correct SmartClientWebDriver methods?
        As mentioned above, you should be calling SmartClientWebDriver methods where possible, so that any custom code has a chance to run. For example. call sendKeys() on your smartClientWebDriver object, rather than on the WebElement. (See https://www.smartclient.com/smartgwt...WebDriver.html.) Right now, it's just a pass through to an Actions object, but if we have to add custom code (as we do for Selenium v1.0 in the user extensions), it won't work unless you call the requested methods.

        Originally posted by dbscott525 View Post
        Part of the single sentence is lost. In my tests I first clear the AutoFitTextAreaItem and then I send a single string. The loss of characters is around the point of text wrapping.

        I tried a variety of ways to work around this problem including only sending a single word at a time. Finally, the only thing that works is sending a single character at a time with sendkeys(). This is OK but it makes the test run 3-5X slower.
        It may be an issue with WebDriver itself rather than our code, but we'll have to investigate to determine this. Are you using the stock Selenium JARs that come with our downloads? If not, which JAR versions? Otherwise, which exact download have you installed?

        Comment


          #5
          Originally posted by Isomorphic View Post
          For example. call sendKeys() on your smartClientWebDriver object, rather than on the WebElement.
          My apologies. I didn’t quite understand the distinction.

          I made the changes so that now my code looks like this:

          Code:
          smartClientRemoteWebDriver.sendKeys(getScBy(), content);
          The behavior did change. Now all characters after the wrap are truncated.

          Originally posted by Isomorphic View Post
          It may be an issue with WebDriver itself rather than our code, but we'll have to investigate to determine this. Are you using the stock Selenium JARs that come with our downloads? If not, which JAR versions? Otherwise, which exact download have you installed?
          We are using SmartGWT 5.0-p20141024.

          We are using Selenium 2.41.0. (I can try switching to a different version of Selenium.)

          We are using SmartClientFirefoxDriver.

          Here is the selenium snippet from our pom.xml

          Code:
          		<dependency>
          			<groupId>org.seleniumhq.selenium</groupId>
          			<artifactId>selenium-java</artifactId>
          			<version>2.41.0</version>
          		</dependency>
          		<dependency>
          			<groupId>org.seleniumhq.selenium</groupId>
          			<artifactId>selenium-firefox-driver</artifactId>
          			<version>2.41.0</version>
          		</dependency>
          		<dependency>
          			<groupId>org.seleniumhq.selenium</groupId>
          			<artifactId>selenium-server</artifactId>
          			<version>2.41.0</version>
          		</dependency>

          Comment


            #6
            Originally posted by dbscott525 View Post
            The behavior did change. Now all characters after the wrap are truncated.
            Didn't you originally report that characters were getting lost? You mean more characters are getting lost with the SmartClientWebDriver API?

            Originally posted by dbscott525 View Post
            We are using SmartGWT 5.0-p20141024.

            We are using Selenium 2.41.0. (I can try switching to a different version of Selenium.)
            SGWT 5.0p ships with Selenium v2.42.2, so you should definitely not be using anything older than that, though you could certainly try a newer JAR to see if that solves the problem.

            Comment


              #7
              Originally posted by Isomorphic View Post
              Didn't you originally report that characters were getting lost? You mean more characters are getting lost with the SmartClientWebDriver API?
              To clarify:
              • With 4.1 webElement.sendKeys characters were getting lost in the middle of the string where wrapping occurs. With 4.1 I didn't try SmartClientWebDriver.sendKeys.
              • With 5.0 webElement.sendKeys the string sent with sendKeys gets truncated after the first wrap point.
              • With 5.0 SmartClientWebDriver.sendKeys the string sent with sendKeys gets truncated after the first wrap point.


              So yes, more characters are getting lost with 5.0 with either webElement.sendKeys or SmartClientWebDriver.sendKeys.

              Originally posted by Isomorphic View Post
              SGWT 5.0p ships with Selenium v2.42.2, so you should definitely not be using anything older than that, though you could certainly try a newer JAR to see if that solves the problem.
              I upgraded to Selenium 2.42.2. This has the same result.

              I upgraded to Selenium 2.44.0, the very latest Selenium release. This has the same result.

              Comment


                #8
                We're not seeing any problem with AutoFitTextArea. We modified the FormVariousControlsSample in the SGWT LGPL Showcase to change the TextArea to an AutoFitTextArea and ran the following WebDriver code (using the Selenium 2.42.2 JARs that ship with SGWT 5.0p and FF24 ESR):

                Code:
                import com.thoughtworks.selenium.*;
                
                import java.util.List;
                import java.util.ArrayList;
                import java.util.regex.Pattern;
                
                import org.openqa.selenium.*;
                import org.openqa.selenium.remote.*;
                import org.openqa.selenium.firefox.*;
                import org.openqa.selenium.interactions.*;
                import org.openqa.selenium.interactions.internal.*;
                
                import com.isomorphic.webdriver.*;
                
                public class WebDriverTest {
                
                    public static void main(String[] args) throws Exception {
                        SmartClientWebDriver smartClientWebDriver = new SmartClientFirefoxDriver();
                        smartClientWebDriver.setBaseUrl("localhost:8080/");
                        smartClientWebDriver.get("index.html#form_controls_various", false);
                
                        By scByLocator = ByScLocator.scLocator("//testRoot[]/member[Class=DynamicForm||index=0||length=3||classIndex=0||classLength=3]/item[title=AutoFitTextArea||index=2||Class=AutoFitTextAreaItem]/element")
                
                        smartClientWebDriver.waitForElementClickable(scByLocator);
                        smartClientWebDriver.click(scByLocator);
                
                        smartClientWebDriver.sendKeys(scByLocator, "enough characters to cause AutoFitTextAreaItem to wrap");
                
                        System.out.println("Done!!!");
                    }
                }
                Setting an Eclipse breakpoint at the println command, we see everything is as expected and the AutoFitTextArea contains:

                Code:
                enough characters to
                cause AutoFitTextAreaItem
                to wrap
                You'll need to provide us with a specific repro case - the SGWT sample code and the WebDriver test code, including all import lines, in order for us to do any more meaningful investigation.

                --

                Note: When tested with FF31 ESR, we observed a slight difference in that the wrapped text looks like:
                Code:
                enough characters to cause
                AutoFitTextAreaItem to wrap
                but there is still nothing lost.
                Last edited by Isomorphic; 28 Oct 2014, 11:32.

                Comment

                Working...
                X