How to assign the text box value to a variable - asp.net-mvc-3

I wanted to get the t#test.com value from the text box which has introduced as the (By.Id("Email")) and compare with the selectEmail value. I have used the following code, but it doesnot take any value which was saved from the text box in the text box. When I debug it I could get only null value for the foundEmail variable.
var checkEmail = driver.FindElement(By.Id("Email"));
string foundEmail = checkEmail.Text;
string selectedEmail = "t#test.com";
Assert.AreEqual(foundEmail, selectedEmail);
Please help me to assign the t#test.com value from the text box to the given variable called foundEmail.
Thankyou

You are using checkEmail.Text please use following code
string foundEmail = driver.findElement(By.id("Email")).getAttribute("value"))
Try it
Thanks.

Related

Fetch value from XML using dynamic tag in ESQL

I have an xml
<family>
<child_one>ROY</child_one>
<child_two>VIC</child_two>
</family>
I want to fetch the value from the XML based on the dynamic tag in ESQL. I have tried like this
SET dynamicTag = 'child_'||num;
SET value = InputRoot.XMLNSC.parent.(XML.Element)dynamicTag;
Here num is the value received from the input it can be one or two. The result should be value = ROY if num is one and value is VIC if num is two.
The chapter ESQL field reference overview describes this use case:
Because the names of the fields appear in the ESQL program, they must be known when the program is written. This limitation can be avoided by using the alternative syntax that uses braces ( { ... } ).
So can change your code like this:
SET value = InputRoot.XMLNSC.parent.(XMLNSC.Element){dynamicTag};
Notice the change of the element type as well, see comment of #kimbert.

vars.put function not writing the desired value into the jmeter parameter

Below is the code which i have been trying to address the below UseCase in JMETER.Quick help is appreciated.
Usecase:
A particular text like "History" in a page response needs to be validated and the if the text counts is more than 50 a random selection of the options within the page needs to be made.And if the text counts is less than 50 1st option needs to be selected.
I am new to Jmeter and trying to solve this usingJSR223 POST processor but somehow stuck at vars.put function where i am unable to see the desired number being populated within the V paramter.
Using a boundary extractor where match no 1 should suffice the 1st selection and 0 should suffice the random selection.
def TotalInstanceAvailable = vars.get("sCount_matchNr").toInteger()
log.info("Total Instance Available = ${TotalInstanceAvailable}");
def boundary_analyzer =50;
def DesiredNumber,V
if (TotalInstanceAvailable < boundary_analyzer)
{
log.info("I am inside the loop")
DesiredNumber = 0;
log.info("DesiredNumber= ${DesiredNumber}");
vars.put("V", DesiredNumber)
log.info("v= ${V}");
}
else{
DesiredNumber=1;
log.info("DesiredNumber=${DesiredNumber}");
vars.put("V", "DesiredNumber")
log.info("v= ${V}");
}
def sCount = vars.get("sCount")
log.info("Text matching number is ${sCount_matchNr}")
You cannot store an integer in JMeter Variables using vars.put() function, you either need to cast it to String first, to wit change this line:
vars.put("V", DesiredNumber)
to this one
vars.put("V", DesiredNumber as String)
alternatively you can use vars.putObject() function which can store literally everything however you will be able to use the value only in JSR223 Elements by calling vars.getObject()
Whenever you face a problem with your JMeter script get used to look at jmeter.log file or toggle Log Viewer window - in absolute majority of cases you will find the root cause of your problem in the log file:

How to set in Report the TextBox visibility by expression in VisualStudio?

I have a simple TextBox in my Precision Design related to a Field in Temporary Table.
I need to show this TextBox only If the it value under Temporary Table is pupulated : so if the value field is pupulated (is a string) I show the Text Box , otherwise I don't show the text Box.
I need to set Visibility by Expression :
Which is the best way forward over ?
Thanks!
You can use iif function. Press fx button, here you can writte your code.
iif function evaluate a condition and return 1 of 2 options, for example, in your case you need show one value only if exist.
check this code:
=iif(fields!YourFieldName.value = "", true, false)
if your field is a number
=iif(fields!YourFieldName.value = 0, true, false)
This code evaluate the value of your field and only populate the value if is complete.

Validate String in UFT

I need to validate a string to see if the string is in BOLD and also if the text is the color green.
Root_TaxDataSummary.SlvObject("FederalBalanceDueAmount").GetROProperty("text")
refundBold = InStr(1,Root_TaxDataSummary,"?")
If refundBold > 0
'Pass
Else
'Fail
End If
Instead property text, I think you should use other properties, for example innerhtml or outerhtml. Then, looking for patterns such as /bdepends on your web object.

Value of type string cannot be converted in system.timespan

I am creating a system where the user enter the time from and time to in a text box inside a repeater, and when I try to assign the textbox value to a local variable it gives me an error
Value of type string cannot be converted in system.timespan
Code is:
m_startTime = CType(Item.FindControl("txttimeFrom"), TextBox).Text
m_endTime = CType(Item.FindControl("txttimeTo"), TextBox).Text
I have to use timespan variable because my database has time(7) datatype column also the stored procedure.
any idea...

Resources