I am unable to enter data in a required field of format __-_______ (it is a 9 digit number) and not getting any errors on console.Cursor entered into the field and moved from starting to end of the field but data not entered.
I have tried below code formats...
driver.findElement(By.id("vendoridentificationnumber")).sendKeys("12-3456789");
--- not working.
driver.findElement(By.id("vendoridentificationnumber")).sendKeys("123456789");
--- not working.
driver.findElement(By.id("vendoridentificationnumber")).sendKeys(s.getCell(3,1).getContents());
--- not working.
Please help me out with this.
Do one thing, without inspecting the element where you want to insert the number simply you can inspect just before element and using Keys class you can jump to your text field and enter your data. Below is a sample line of code
d.findElement(By.xpath("")).sendKeys(Keys.TAB,"enter your value");
Hope it'll work.
Use javascript to enter the value in the textbox.
Eg :
$('#textboxid').val('test')
Related
I'm using TestCafe for test automation of a web application based on the Wicket framework. I try to type text into a text input field ... well, actually it is a dropdown list, where a text input field appears, so that the user can search for certain codes. The HTML fragment is as follows:
HTML fragment
And here is the corresponding screenshot (text field above "001"):
Text input field with dropdown
The user can type some characters and the list below is automatically filtered (I did this manually):
Text input field with some text
My TestCafe test tries this:
.click( productcodeList )
.expect( productcodeInputField.visible ).ok()
.click( productcodeInputField )
.typeText( productcodeInputField, 'ABW' )
i.e.
Click on the drop down list.
Assume that the text input field is now visible (works fine).
Click on the text input field (this should not be necessary, since typeText() is supposed to do this anyway).
Type the text "ABW" into the text input field ==> This does not work.
I'm sure that my Selector works, since the assertion (expect) is successful and when I debug the test run after the second click (on the text input field), I see the following:
TestCafe screenshot
I.e. the cursor is directly on the text field, but somehow TestCafe cannot write the text into the field.
Some additional information: The Selector for the input field is created as follows:
productcodeInputField = Selector('span').withAttribute('class', /select2-dropdown.*/ ).child('span').withAttribute('class', /select2-search.*/ ).child('input').withAttribute('class', 'select2-search__field' );
More information: I'm using the same logic on the same page:
kurzbezeichnungField = Selector('input').withAttribute('name', /.*aeAbbreviation.*/);
...
await t.click( kurzbezeichnungField )
.typeText( kurzbezeichnungField, 'xxxWWW' )
and this works fine.
Node.js version: v10.16.3
Testcafe version: 1.5.0
This issue looks like a bug. However, I cannot say it precisely without an example that demonstrates the problem.
My team would really appreciate it if you share your project or sample to demonstrate the issue.
Please create a separate issue in the TestCafe github repository using the following template and provide as much additional information as possible.
I'm automating e2e tests with Protractor on an angular app.
However, I have an issue when sending keys on input fields.
The sendKeys would miss few characters everytime so I found a workaround :
static sendKeys(value, element){
value.split('').forEach((c) => element.sendKeys(c));
}
This works well but it takes more than 3 times the time the original sendKeys function would.
Well no problem my tests are still functionnal right ?
My app now has new fields with scripts behind them.
One of them is a datepicker input, you can either choose from the datePicker or type it manually. However, for today's date you would type 09022018 and the slashes are automatically appended at the right place (like so 09/02/2018). If you were to enter a wrong date the field is cleared.
Now back to the problem : it seems that both my implementation of sendKeys and the original one loose focus after each submitted key. This means that I can't enter a valid date in the input field as it's cleared after each simulated keypress.
I could use browser.executeScript to fix it but I wouldn't be able to test the functionnality adding slashes. Also, as you type, the datepicker is still open and refreshes after each keypress, you can select a date from it at any time and that is also a feature I want to test.
Thanks in advance
Use executeScript to set the date in backgrond, then use sendKeys to enter a space or Tab at the end to trigger the Keyborad event which will check the input and format the input with slash
function enterDate(date) {
var script = 'arguments[0].value=arguments[1]';
// input box for date
var dateBox = element(by.xxx(yyy));
browser.executeScript(script, dateBox, date);
dateBox.sendKeys(" ");
// or try send Tab
dateBox.sendKeys(protractor.Key.TAB);
}
enterDate('09022018');
You can try this solution on other fields you fixed but take 3 more time.
This only happens on Safari with SafariDriver:
For a textinput element, clear() can clear the field indeed, but the following values sent using sendKeys() are actually extended with the original value.
Example:
Start -- input value: 1
input.clear() -- input value: empty
input.sendKeys(2) -- input value: 12
Also tried
sendKeys(Key.HOME,Key.chord(Key.SHIFT,Key.END),newVal) to select all and replace, but this simply not working. Nothing was selected.
Any suggestion is appreciated.
Try to click element first and then use clear() method to clear text, it works for me many times may be for you also:
WebElement myInputElement= driver.findElement("Locator value");
myInputElement.click();
myInputElement.clear();
myInputElement.sendKeys('Testing');
I am going to a field, entering text, saving it, then going back to verify the value is still in the field.
$I->waitForText is not working. Not sure why. I am trying the following but getting the error below:
$I->canSeeInField("//form[#id='Foo']/table/tbody/tr[3]/td[3]/textarea", "123");
Sorry, I couldn't see in field "//form[#id='Foo']/table/tbody/tr[3]/td[3]/textarea","123":Failed asserting that two strings are equal.
Any ideas?
Thanks
If you are using WebDriver, you can just debug your page using makeScreenshot()
You can just use:
$value = $I->grabFromField('//form[#id='Foo']/table/tbody/tr[3]/td[3]/textarea');
and fill other fill with your value:
$I->fillField('#your_field_id', $value);
and than, just make a screenshot:
$I->makeScreenshot('name_of_your_screenshot');
Now check your debug folder with your image.
I am new in selenium and trying to learning. I am creating a script and I got stuck here, I want to store a dynamic value from text message on web page ex. " Event Name:Test" this Event Name is dynamic and I want to store this and want to get in other window. In 2nd window i want to use this value(Test) to verify in the page
I tried storeValue, StoreText and storeAttribute command and getting error message for xpath or "element not found".
Please help me and advice me , what should I do?
Can You please suggest me the Xpath for storing and retrieving the event name. Please help me...
Thanks in advance,
Niru
If you are using the same test-case to navigate from page 1 to page 2 you can use the storeText function in the IDE to store the value of your event name. And then you can use the same variable in the page 2 for verification.
For example, in page 1 to store the value of event you use:
storeText(locator1, temp)
And then on page 2 you use assert:
assertText(locator2, ${temp})