Codeception- "Failed asserting that two strings are equal." when using $I->canSeeInField - codeception

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.

Related

How to find an element containing #nbsp; in text?

I've an element with html -
<h3>App-1 Playground Login</h3>
I want to identify it with entire text - App-1 Playground Login, but causing issues to identify it. Please help how this element can be identified.
Please use the below xpath. I have already tested that and it is working fine. In the second argument of the translate method you need to type "ALT+0160" and in the third argument you will have to put just a normal space.
//h3[contains(translate(text(),' ',' ' ), 'App-1 Playground Login')]
One of the way to select your title could be :
//h3[text()= concat('App-1 Playground',codepoints-to-string(160),'Login')]
Works fine on http://xpather.com/

I am unable to enter data using send keys

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')

Calabash-android: How do I read text which comes from an API?

I want to read the text which comes from API end, When I query (query("*")) it does not appear on the calabash-android console.
wait_for_text(text, timeout: 10) does not work either.
query "all * marked'Email field can not be empty'"
Calabash doesn't return results that are not visible by default. So if the error message is on the screen but just invisible, using the all operator should do the trick.
In android two different message can show in edit text field by using hint text and error text
if its hint text use this:
query("* id:'edit_text_id'", :hint)
if its error message use this:
query("* id:'edit_text_id'", :error)
Normally these kind of text messages won't show by querying -> query("*")

Clear TextField rather than append

I'm using the following statement to clear text filed value:
input.value("abc")
input.value("")
input.value("def")
But, instead of clearing and set new value, it is appending the new value to old value. ('abcdef').
Is there any way to clear the TextField, before setting new val?
You can clear using the selenium element:
input.firstElement().clear()
And you can send keys using << like so:
input << "abc"
You can use the selenium Keys to backspace the texts that you already had entered. You can try many different ways to accomplish that. Here is a simple way to do that:
import org.openqa.selenium.Keys
input.value("abc")
input.value(Keys.chord(Keys.CONTROL, "A")+Keys.BACK_SPACE)
input.value("def")
It should do the job. Let us know whether it worked for you or not!
Cheers#!

How to create Test cases in Automation tool TestComplete

How can I create test cases according to my requirement.
Example:
I have a form with many fields. There is one field name Father's Name, now I want that the user should insert only string in this field, no numeric values should be accepted.
I wanna carry out such cases and do testing using the tool. How can I do this in TestComplete?
So, you want to validate that the tested application correctly handles the situation when forbidden characters are entered in the field, right? If so, then the exact solution depends on what the application does when a forbidden character is entered:
1) The app shows an error box. In this case, make your test enter a forbidden char and check for the error box existence using the appropriate Wait* method (WaitWindow, WaitNamedChild, etc.). Short example from the top of my head (did not run the code):
var TextToEnter="First 123Name";
EditBox.Keys(TextToEnter);
// As a rule, validationg is performed when the focus changes
EditBox.Keys("[Tab]");
var ErrorBox = MainWnd.WaitNamedChild("wndErrorDlg", 5000);
if (ErrorBox.Exists)
Log.Message("Succeeded - the error box is shown");
else
Log.Error("Failed - no error box detected");
2) The app does not show any error, but just ignores the forbidden chars making them not to appear in the edit box. In this case, just compare the actual text against the expected text. Something like this:
var TextToEnter="First 123Name";
var TextToExpect="First Name";
EditBox.Keys(TextToEnter);
if (EditBox.wText == TextToExpect)
Log.Message("Succeeded");
else
Log.Error("Failed");
I hope this helps.