how to clear a text edit field? android python appium - android

how to clear text edit field? android python appium?
I tried that way:
el = driver.find_element_by_id('text edit field id').clear()
el.click()
el.clear()
however, it actually deletes only one symbol.
I think may by call an el.click() twice and send keycode to delete highlighted text area but how to highlight the text?
Interestingly, such problem reproduces in Sony Xperia z3 compact, android 5.0.1.
In lg, nexus android 4.4,5.1 accordingly, the above code works well

i had faced same issue with my android application but i am doing automation in java , so for the solution i am performing tap Action twice near the location of the element so it will select all the text which already written in text field and after that click on that "cut" symbol so it will clear text field.
i have written a method for sendkeys in android device.
public void typeForAndroid(AppiumDriver appiumDriver,WebElement ele,String text)
{
if(ele.getText().isEmpty())
{
ele.sendKeys(text);
}
else
{
TouchAction action=new TouchAction(appiumDriver);
action.tap(ele.getLocation().getX()+5, ele.getLocation().getY()+5);
action.tap(ele.getLocation().getX()+5, ele.getLocation().getY()+5);
appiumDriver.performTouchAction(action);
pause(2);
try{
appiumDriver.findElementById("android:id/cut").click();
}
catch(Exception e)
{
appiumDriver.sendKeyEvent(67);
}
pause(2);
ele.sendKeys(text);
}
}
this is working for me. I hope this might works for you.
in this i have used appiumdriver but you can also use androiddriver.
Thanks

Related

Xamarin.Forms Entry.Focus() is not working in Android 9 and 10

In a sample Xamarin.Forms application we are trying to focus an Entry field after it becomes Visible on a Button Click
Below is the code snippet we are using to achieve above behavior I mentioned
void OnClick(object sender,EventArgs arg)
{
searchEntry.IsVisible = true;
searchEntry.Focus();
}
This is working fine in all iOS devices and android devices below 9 for android 9 and 10 the keypad shows up but the typed letters are not getting reflected in the Entry fields.
Can anyone have experienced the same issue before? Please let me know if there is any solution for that in the Answers section.
Give device some time to process previous request.
(void)OnClick(object sender,EventArgs arg)
{
searchEntry.IsVisible = true;
await Task.Delay(500);
searchEntry.Focus();
}

How to hide error message after right value selected from select box in jQuery.validationEngine along jquery mobile?

I am using jQuery validationEngine with jQuery mobile plugin in my mobile page, am validating the dropdown list if it has empty value once I set proper value the error message is not getting in hide samsung galaxy android phones but same is working fine in sony xperia and also in normal web browser(PC), can somebody help to fix this ..
specifications,
jQuery Validation Engine 2.2, jquery-1.8.1.min, jquery.mobile-1.1.1.min,
along with symfony 1.1
The above is working fine in Android 4.0 but not working in android
2.2 and 2.3
Thanks in advance,
Finally I got solution for the my problem...
I override the validationEngine method on those fields on change of the select box,
$('#day').change(function(){
if( $(this).val()!= '日'){
$("#day").validationEngine('hide');
}
else {
$("#day").validationEngine('showPrompt', '* 半角数字でご入力して下さい。', 'red',"topLeft",true);
}
$("#confirm").validationEngine('detach');
$("#confirm").validationEngine('attach',{promptPosition : "topLeft"});
});

Highlight a specific text in WebView android 4.0

I want to highlight a specific (searching) text on WebView. I use the code
myWebView.findAll(txtSearch);
try {
for (Method m : WebView.class.getDeclaredMethods()) {
if (m.getName().equals("setFindIsUp")) {
m.setAccessible(true);
m.invoke(myWebView, true);
break;
}
}
} catch (Exception ignored) {
}
This works great on Android 2.2, but it doesn't work on Android 4.0 and above
Yes, you are right, highlight text on WebView works great on Android 2.2, but he appeared as not working on Android 4.0 and above
look at this link
here
i am also trying this highlight of text ,it is working perfectly on
android version 2.2 but if i am trying the same thing in another
version than the highlight text is not shown and one more thing that
findasync() only works for api 16 .May be using java script can help i
am working on that if it works i'll tell to you.
thanks

Android:cannot make a selection after WebView search with highlight

Hello I have a bug in my app and I cannot figure it out.
I want to search for text in my WebView and get the found Text highlighted
for Android 1.5-2.3 this works quite well
public void onClick(View v){
webView1.findNext(true);
int i = webView1.findAll(findBox.getText().toString());
try{
Method m = WebView.class.getMethod("setFindIsUp", Boolean.TYPE);
m.invoke(webView1, true);
}catch(Exception ignored){}
}
}
for Android 3.0+ I have to use the JavaScript workaround from here, because Google doesn't support the highlighting of searched text for incomprehensible reasons
And now my Bug: After the search on my WebView I get the highlighted Text, and I can't select the Text anymore. The only fix I could use is the JavaScript workaround in older Android versions, too. But the function runs very slow and it takes about 10 seconds until the text gets highlighted. I Hope someone has a better solution/fix :)
Thank you
I use the same for 3.x then it did not work on 4.0.x.
Yesterday I updated to 4.0.4 and now highlight works again.
So the solution can be found in the 4.0.4 sources.
OK I have found a quite good solution.
Here is a JavaScript code for Highlighting, that runs really fast :) http://4umi.com/web/javascript/hilite.php#thescript
Anyway I don't understand, why I can't selecting text after the of the official Webview search
For Android 3.x I used webview.showFindDialog(stringtofind, true);
use findAllAsync() instead , finAll() is deprecated in API 16;

Selecting text on TextView (android 2.2)

How to implement selecting text capability on Android 2.2? I searched Google but can't find a solution.
This is the only way I've found (from google) to support it for android 1.6+, it works but it's not ideal, I think in stock android you can't hold down a webview to highlight until v2.3, but I may be mistaken..
By the way this is for a webview, it might also work on textview, but I haven't tried it
(Note: this is currently what my shipped app is using, so it works with all the phones I've had it tested on, but the only reason I found this question was because I was searching and hoping that someone had come up with a better way by now)
I've just got a menu item called "Select text" which calls the function "selectnCopy()"
#Override
public boolean onOptionsItemSelected(MenuItem item) {
//..
switch (item.getItemId()) {
case R.id.menu_select:
selectnCopy();
return true;
//..
}
}
Which looks like this:
public void selectnCopy() {
Toast.makeText(WebClass.this,getString(R.string.select_help),Toast.LENGTH_SHORT).show();
try {
KeyEvent shiftPressEvent = new KeyEvent(0, 0, KeyEvent.ACTION_DOWN,
KeyEvent.KEYCODE_SHIFT_LEFT, 0, 0);
shiftPressEvent.dispatch(wv);
} catch (Exception e) {
throw new AssertionError(e);
}
}
Notice I've put the select_help string there as a toast, that's just because it's not immediately clear to the user how it's supposed to work
<string name="select_help">Touch and drag to copy text.</string>
The Link #Stefan Hållén provided only worked after API Level 11.
And Android 2.2 is API Lv.8, that's the reason why you cannot get a resource identifier.
Have you set the text to be selectable? like this:
android:textIsSelectable="false" //OR true
See the Documentation for further reference.
After a long and time consuming search, I can't find a component that can select text in textview for android API level <=11. I have written this component that may be of help to you :
new Selectable TextView in android 3 (API <=11) component
An interesting workaround:
You could try displaying your text in a webview.
You just have to write the HTML tags and all of that into your string to display, and it should be selectable using the WebKit browser.
This should be fairly lightweight and transparent to the user, and I think it would solve your problem.
Let me know if you need a code example, it should be fairly simple. Just check out the WebView docs on http://developer.android.com/resources/tutorials/views/hello-webview.html
Best of luck!

Categories

Resources