How to clear material UI textfield with webdriver - webdriver

please I have problem that i am not able to clear text which is in Material-Ui text field.
driver.findElement(By.id("CompanyNameField")).clear();
will clear the field, but when switching to another tab with
driver.findElement(By.id("CompanyNameField")).sendKeys(Keys.TAB)
will cause that value previously cleared is back in text field.
Please any ideas how to clear this field permanently?
Thanks

Sending backspace keys to the form worked for me:
from selenium.webdriver.common.keys import Keys
element = driver.find_element_by_css_selector(cssSelector)
for _ in element.get_attribute('value'):
element.send_keys(Keys.BACKSPACE)

Related

How to insert text into popup using Robot framework?

I have a button on clicking on it it is opening a Popup. The Popup contains below fields like., Textbox, OK and Cancel buttons. I am fine with cancel and Ok buttons. Help me in Giving text to that textbox using Robot Frame work. I am not able to find the Id/Name/Xpath of that particular field.
Assuming that the popup is a proper window and not an alert, you just need to select the window after it pops up. After that, your usual keywords like Input Text will work as expected.
The selenium2library user guide explains how to do this.
Input text is the way to go about this but what the locator is depends on how you are creating this pop-up. Please show us the code you are using to create the pop-up and then we can help you to add a locator to it. Generaly I use jquery locators as they are incredibly powerful so I would recommend looking to that as a way forward.

ASPxTextBox wih NullText loses value when browser window loses focus

I have an ASPxTextBox with a NullText. It is used for a user name. Some users are copying their user name from the registration email into this text box. When they do it via right click and the context menu and go back to their email client to copy the password, the text box gets emptied, i. e. NullText is displayed.
I can reproduce this. However, when using Ctrl+V to paste the user name, it is persistent.
It seems to me that the ASPxTextBox is looking for a keydown event or something similar to decide if the text has changed.
How can I make the text persistent in all cases?
It seems that this behavior is a side effect of the browser/form AutoComplete feature.
Can you try to reproduce this issue with a regular with the placeholder attribute (HTML5)?
If the behavior is the same, see this thread.
I am working around this issue with this jquery plugin:
https://github.com/mathiasbynens/jquery-placeholder

How to keep focus on Spark TextInput after setting StageWebView source

I have a mobile application that has a Text Input used for searching. Below the search TextInput is a StageWebView. When I set the source of the StageWebView using loadURL() the key input is shifted to the StageWebView.
How can I prevent this?
I think I figured out the problem. When you set the stage property (which is basically setting the visibility to true) that's when it steals the focus. I was showing and hiding the web view depending on if the text input had any text (I was updating the webview source on text change). The fix was to set the web view to visible before putting the cursor in the Text Input. As long as the visibility doesn't change the focus stays in the text input.
I dont know if there is a better way but my solution is to try to set the focus back to the textInput by using myText.setFocus() after your load routine.

Qt show message box with text input

Is there any easy and clean way to show a message box in Qt4 (PyQt4 actually) with support for text input rather than just selecting a button from a predefined list? I can (and have partially) done this by writing a custom class just for displaying such dialogs but isn't there a cleaner way?
EDIT: I got it working thanks to Luca Carlon. However just in case someone else needs this, I'll post working PyQt4 code here below
from PyQt4.QtGui import QInputDialog
#This code works only inside a method of a widget or window as self must refer to a
#valid widget or window to get the correct modality, although we can give None instead
(text,truth)=QInputDialog.getText(self,"Get text","User name",QLineEdit.Normal,"NoName")
if truth:
#The user has accepted the edit, he/she has clicked OK
print text
else:
#The user has not accepted the edit, he/she has clicked Cancel
print "No change"
Use QInputDialog for that. The static method getText might be sufficient for you.

Flex; recognize email addresses as object in a text field

I am searching for a way to convert an email address once entered in a textfield as an object like shown in this image on MS office outlook ;
alt text http://img830.imageshack.us/img830/4765/41913045.jpg
the point is that now in outlook as my cursor is positioned just after "user2#gmail.com" if I click backspace I will delete the entire email address, as if it was one object and not simple text entered.
I suppose this is possible in flex? All ideas and suggestions are more than welcome.
IT is possible; but you'll probably have to create a component for doing so.
I believe Hillel Coren's AutoComplete component supports "multiple select" functionality in this manner. Just check out the demo. I'm not sure of the customization for that, though.

Resources