Sendkeys with Arabic text issue


#1

Hi,
I am unable to send arabic text in a text field by using the .sendkeys(“الشرق”) command using selinium for Android App. I tried to convert the string using the charset UTF-8. but not displaying the ARABIC text or Arabic- English combination text in the text field. Kindly let me know if anyone face similar issue and solved it.

Please see the below appium log
[HTTP] --> POST /wd/hub/session/9909c131-6d14-4068-93be-0983308b901a/element/9/value {“id”:“9”,“value”:[“الشرق”]}
[MJSONWP] Calling AppiumDriver.setValue() with args: [[“الشرق”],“9”,“9909c131-6d14-4068-93be-0983308b901a”]
[AndroidBootstrap] Sending command to android: {“cmd”:“action”,“action”:“element:setText”,“params”:{“elementId”:“9”,“text”:“الشرق”,“replace”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got data from client: {“cmd”:“action”,“action”:“element:setText”,“params”:{“elementId”:“9”,“text”:“الشرق”,“replace”:false}}
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command of type ACTION
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Got command action: setText
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Using element passed in: 9
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Attempting to clear using UiObject.clearText().
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Text remains after clearing, but it appears to be hint text.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Text not cleared. Assuming remainder is hint text.
[AndroidBootstrap] [BOOTSTRAP LOG] [debug] Sending plain text to element: الشرق
[AndroidBootstrap] Received command result from bootstrap
[MJSONWP] Responding to client with driver.setValue() result: true

Thanks…


#2

try:

// java-client: 5.0.0-XXX, Appium: 1.6.5-xxx

// set value
(AndroidElement) el.setValue(your_text)

// replace value
(AndroidElement) el.replaceValue(your_text)

#3

Dear Aleksei, Thanks for your support feedback.

My current configuration is
Java-Client 5.0.0-BETA6 , Appium v1.6.4

I tried the above but it fired cast exception as " java.lang.ClassCastException: com.sun.proxy.$Proxy12 cannot be cast to io.appium.java_client.android.AndroidElement ".

I have created the page object with each element identified as Webelement. I am not sure whether this is wrong. Kindly guide me.

Below is my element identification script
@FindBy(id=“com.talabat:id/search_area”) private WebElement txtSearchArea;

Code is :
AndroidElement element = new AndroidElement() ;
element=(AndroidElement) txtSearchArea;
element.setValue(Area);


#4
@FindBy(id="com.talabat:id/search_area")
private WebElement txtSearchArea;

->

@AndroidFindBy(id="search_area")
private AndroidElement txtSearchArea;

and code is:

txtSearchArea.setValue("someText")

#5

Thank You… I will try this now.


#6

Dear Aleksei,
I only worked Page objects with Webdriver page object initialization.

I tried the above , currently it throwing me the error
java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;J)V

I tried the page initialization using PageFactory.initElements(new AppiumFieldDecorator(driver), this); and
PageFactory.initElements(new AppiumFieldDecorator(driver, 10, TimeUnit.SECONDS), this);.

Both giving same error. Kindly help.

Kindly help.


#7

@semrafi i did not ask you to change in Page something. i have same “initElements” as you are.

public abstract class Page {
    public Page(WebDriver driver) {
        this.driver = driver;
        PageFactory.initElements(new AppiumFieldDecorator(driver, defaultLook, TimeUnit.SECONDS), this);
    }
...

public class XXXXX_page extends Page {
    @AndroidFindBy (id = "activate_fingerprint")
    private List<AndroidElement> mainContainer;


    public XXXXX_page(WebDriver driver) {
        super(driver);
    }

    public boolean tapDeclineButton() {
        System.out.println("  tap Decline button");
        try {
            return tapElement(bottomLayout.findElements(MobileBy.className("android.widget.TextView")).get(1));
        } catch (Exception e) {
            return false;
        }

    }
...


//test code
public class BaseTest {
    protected static AppiumDriver driver = null;
    protected static AppiumDriver driver_2 = null;
.....

public class xxxxXXXX extends BaseTest {
        xxxPage = new xxxPage(driver);
        assertTrue("'xxxx' screen NOT loaded", xxxPage.isxxxPageLoaded());
...

#8

Dear Aleksei,
Let me try what is the problem for the above error(java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkArgument(ZLjava/lang/String;J)V) from my side , If I am unable to solve, Kindly i may need your support more… Thank You so much.


#9

Could anyone please help me, I am still not able to resolve the issue with page factory.
The question may be so basic, Please answer.
Can we have the WebElement and Android Element in the same page and initialize the page using AppiumFieldDecorator.
I am trying in that way and not working , I am not sure whether this is correct. below is the code i used in the page.

The same element i am identifying using the below in same page

public class SelectArea extends BaseClass {

@FindBy(id="com.talabat:id/search_ar") private WebElement  txtSearchAr;
@AndroidFindBy(id="com.talabat:id/search_ar") private AndroidElement txtSearchArAndroidBy;

//and initialize the page by constructor as
public SelectAr(AndroidDriver TestDriver)
{
driver =TestDriver;
PageFactory.initElements(new AppiumFieldDecorator(driver), this);

}
}

And driver initialized as
driver = new AndroidDriver(new URL(“http://127.0.0.1:4723/wd/hub”), capabilities);

Issue I am getting is
java.lang.NoSuchMethodError: org.openqa.selenium.support.ui.FluentWait.until(Ljava/util/function/Function;)Ljava/lang/Object;
at io.appium.java_client.pagefactory.AppiumElementLocator.waitFor(AppiumElementLocator.java:91)
at io.appium.java_client.pagefactory.AppiumElementLocator.findElement(AppiumElementLocator.java:112)
at io.appium.java_client.pagefactory.interceptors.InterceptorOfASingleElement.intercept(InterceptorOfASingleElement.java:61)
at io.appium.java_client.android.AndroidElement$$EnhancerByCGLIB$$c0b591f0.replaceValue()

Thank You.


#10

Hi I got solved (by upgrading selinium version to the latest one) the above issue with Page Factory initialization for Apps using appium , just commenting here as it would be helpful if anyone else face the same issue.

org.openqa.selenium.support.ui.FluentWait.until(Ljava/util/function/Function;)Ljava/lang/Object;
The above error will throw if you use maven project with Selinium dependency version 3.2. It isdue to exception from fluent wait.
It is fixed from Selenium version 3.2.0 and above. You can refer the selinium relase note for the same ( https://github.com/SeleniumHQ/selenium/blob/master/java/CHANGELOG#L18-L19).


#11

Dear Aleksei,
I tried by setting the value using keyword txtSearchArea.setValue(“الشرق”) . But it is not displaying the given value in the Text field ,also no error is getting displayed.
Did any of you could support me to find out the solution. I am really stuck here, as my apps having Arabic version to test.

Highly appreciated you help.

Thanks,
Semeena.


#12

Did you set “true” unicodeKeyboard property when you start driver?


#13

Thanks for the Reply… I didn’t set , Could you share the format , I will try.
Ok I got it. I will try and let you know… Thanks


#14

Yes , I tried now by setting the capability as
capabilities.setCapability(“unicodeKeyboard”, true);

But still it is not displaying the Arabic text value in the text field and no error generated with Appium v1.6.4.


#15

Kindly suggest if I could try with any other way?

Thanks


#16

Hi Aleksi,
I tried to input Arabic text in the text field with reference to this link http://appium.io/slate/en/master/?java#multi-lingual-support , but not working …It fired the below exception : Caused by: java.nio.charset.UnsupportedCharsetException: x-IMAP-mailbox-name
at java.nio.charset.Charset.forName(Charset.java:531)
at com.helperAPI.UnicodeEncoder.(UnicodeEncoder.java:14)


#17

@semrafi never tried Arabic for EDIT (only for search) . try also:

(Alternatively, on the device, access Settings, then Language & Input. Make sure Appium Android Input Manager for Unicode is selected, and finally go to Default and set it to Appium Android Input Manager for Unicode.)

maybe you need also try to add ARABIC keyboard and set it as DEFAULT! - just idea.


#18

Thanks for the Reply. I tried in that way only, but not working… Arabic is not getting printed in the Text Area field…


#19

@semrafi ok. i tried myself - https://screencast.com/t/7CzA1nAwZgT

what i did:

  1. added:
capabilities.setCapability("unicodeKeyboard", "true");
  1. email text was updated to “sendKeys”
emailInput.sendKeys(text);

and it started to work.


#20

Sounds great…But the same I tried and not worked in Samsung S7… Which device you used?