This may seem odd, but it's a requirement for a project I'm working on. I have a MVC view that provides a UI to search a Lucene index. Once the user inputs something to search on and presses the submit button, the URL looks something like this:
http://.../IMS/Demographics?searchTerm=64453&searchDefault=True&page=1&pageSize=10&ascending=True
The "searchDefault" variable is Boolean, as is the ascending variable. However, the searchDefault variable is displayed with a checkboxfor on the search view. So, if I change "searchDefault=True" to "searchDefault=True%27B", I get "An exception of type 'System.InvalidOperationException' occurred in System.Web.Mvc.dll but was not handled in user code". The debugger points to the seachDefault checkboxfor as the problem, because I'm trying to shove a string into a Boolean. Well, I wrote a Catch for that exception in the Search method, so I'm not sure how to validate or remove the erroneous characters before the URL is executed and it hits the controller Search method. I validate and remove special characters within the Search method, but this error seems to occur earlier.
Any information on how to catch this would be appreciated. If this type of security issue has a name, I'd like to know that too. Thank you.
Related
I'm trying to get a list of IwebElements that contain the attribute aria-required. Reason why I'm trying to get this list, is so that i can check if all required fields are necessary for the user to fill out, before he can continue to the next page.
So far after 2 days of searching I'm still convinced that it shouldn't be that hard. I'm using the expression:
".//*[#aria-required='true']"
From my research that would mean that it will search for ALL the elements starting from the root of my webdriver.
[TestMethod]
public void CreateProjectWithoutRequiredFields()
{
GoToProjectPage();
tracking = CM.GoToNewlyCreatedFrameAfterClickButton("ftbNew", tracking, theDriver);
CM.Wait(2000);
bool succesSave = false;
CM.LogToFile("Create project whitout required fields", tracking);
foreach (IWebElement e in theDriver.FindElements(By.XPath(".//*[#aria-required='true']")))
{
FillDataInNewProjectPage();
e.Clear();
CM.GetDynamicElementById("btnSave", theDriver).Click();
try
{
CM.GetDynamicElementById("titel", theDriver).Click();
}
catch (Exception)
{
succesSave = true;
NUnit.Framework.Assert.IsFalse(succesSave, "The page is saved with succes, without entering text in the following required fields : " + e.GetAttribute("id").ToString());
}
CM.Wait(1000);
}
}
I will try to explain what i did here:
First i went to a overview page with all my existing projects. On this page i clicked the ftbNew button to create a new project. The driver is automatically switch to the correct frame (i now the right frame is selected because i used this line on other page's.)
then the line
foreach (IWebElement e in theDriver.FindElements(By.XPath(".//*[#aria-required='true']")))
{
should normaly find a the elements in my driver with an attribute "aria-required='true'"
Then it would fill in the page with data, clear the first element that is found from its data en try to save it.
if the element titel is found on the page, than we are still on the same page en the save action wasn't successful ( <- so this is good)
so next we again overwrite every field on the page and clear this time the second element that is found.
en so on...
What I'm guessing, that xpath has difficulty finding the 'old' aria-required attribute... When i try to validate my expression using firebug and other xpath checkers, the aria-required attribute isn't always present. Sometimes it finds the input field sometimes it doesn't.
source code page
As you can see in the firebug console not all attributes are loaded, account-manager has a aria-required attribute, but project leader doesn't. If i inspect the element again, but this time click project leader. The attribute will be loaded. Very strange....
Extra info: I am using frame's and i know a lot can go wrong if you are situated in the wrong frame, but i am sure that he is looking in the correct frame. Especially because i can't find the elements using firebug with the above expression. If i change my expression to .//input, it will find the elements but also selects input fields that aren't required.
In advance i want to thank everybody that want to look into my problem :)
Adriaan
Based on your description of the behavior on the page, you cannot rely on the aria-required attribute to indicate a required field. I think that you should go back to the developers of the site to ask them to give you a reliable handle. It may be as simple as looking for the "*" as the last character of the label associated with the input field, but that's kind of annoying to have to deal with.
As an aside, you should consider catching a more specific exception for your success case. Right now, if ANY exception happens, you'll declare success, but that may not be what you really want to do.
So these days I am trying to work with the TFS API. So far it was good, but all of a sudden.. I want to retrieve specific story's work items and their respective information using a search by ID method to pick the correct story. In order not to miss some important information I am doing SELECT * in my queries. I get the story, I get the Tasks.. But there seems to be problem with few of the fields - namely AreaPath, IterationPath and Type. As a primitive check I've written down some Console prints to check what's good and what's not - so if I uncomment any of the three previously named on execution this exception is thrown: A first chance exception of type 'Microsoft.TeamFoundation.WorkItemTracking.Client.FieldDefinitionNotExistException' occurred in Microsoft.TeamFoundation.WorkItemTracking.Client.dll.
Here is what I am trying to print out:
Console.WriteLine(target.Fields["Title"].Value);
Console.WriteLine(target.Fields["Description"].Value);
Console.WriteLine(int.Parse(target.Fields["Id"].Value.ToString()));
Console.WriteLine(target.Fields["AreaPath"].Value); //Problem 1
Console.WriteLine(target.Fields["IterationPath"].Value); //Problem 2
Console.WriteLine(int.Parse(target.Fields["AreaId"].Value.ToString()));
Console.WriteLine(int.Parse(target.Fields["IterationId"].Value.ToString()));
Console.WriteLine(target.Fields["State"].Value);
Console.WriteLine(target.Fields["Type"].Value.ToString()); //Problem 3
With or without ToString() nothing really changes.
Any suggestions ?
EDIT: They are not null, I've checked while in Debug mode, they all have assigned values.
Use CoreField or builtin getters:
Console.WriteLine(target.Fields[CoreField.Title].Value);
Console.WriteLine(target.Fields[CoreField.AreaPath].Value);
Console.WriteLine(target.State);
Console.WriteLine(target.Type.Name);
I am using the QuickBooks SDK in C# .NET to add /edit vendors in my QuickBooks. When I make a request with multiple errors, say like passing more than allowed number of characters for both Name field and Address1 field, QuickBooks always returns only the first error. It does not return all the errors that I make. How to return all the errors?
The status message says I am tryin to enter more than the allowed no of characters for the Name field, but doesn't mention anything about the Address field for which I am also passing more than allowed no of characters. If I pass a proper value for Name and make a error in Address1 field, then it gives me error in that field.
I want to get all the errors at one go. How can I get it?
I am looping through the ResponseList and displaying the error but the ResponseList.Count is also always 1. What is the way to get errors in all the fields that I am passing in a single request?
How to return all the errors?
You can't. QuickBooks itself does not support this - it always just returns the first error it runs into.
The allowed values, data lengths, and data types are very well defined in the XSDs/OSR. You should be able to easily build some validation into your own application to catch these errors/enforce correct data entry before submitting the data to QuickBooks.
I want to get all the errors at one go. How can I get it?
What is the way to get errors in all the fields that I am passing in a single request?
You can't. QuickBooks doesn't support this.
I'm reading a tab delimited text file into a String[]. Then, go thru the array line by line, split it into individual elements (currentLine.Split('\t')), make changes to the elements as needed, and then do a Parameters.Add to add each element as a parameter to the query string.
For the most part, it works and has added stuff to the Access table. However, it hit something in the data that it didn't like, and I'm having trouble determining which element is causing the data mismatch. The only error I'm getting (VS Express 2012) is Data type mismatch in criteria expression.
Is there a way to see which parameter is causing the error? I can tell which line it is by looking at what's already been added to the table, but I don't see where the problem is.
Thanks!
Your question seems pretty general although here are some techniques that will help you resolve it:
Wrap your database insert/update statement in a try / catch. Within the catch block write the parameters that were active at time of the insert.
Inspect the exception for an inner exception that will likely have more specific details of the invalid parameter/value.
i have placed a SqlDataSource component on my aspx page but while configuring the SqlDataSource in the "Test Query" Step I am passing the following parameters :
But when i click ok it returns following error:
This error occurs when i pass the string :
INFO, WARN, ERROR,
I have tried a lot of combinations but nothing works. It works only if i pass one of the three words in single quotes like this :
'ERROR'
Infact the INFO WARN and ERROR are the various levels available in the table. Each record can have only one level and in the sql query i am using IN("-----") to match the criteria, hope you understand.
Any idea to pass the string with comas between them will be highly appreciated.
After you create the page with the dialogue helpers, just switch to code view of your html and change them by hand on the created code...
I have resolved the problem by passing each level in single quotes without , after the last level as shown in the image below:
Anyway thanks for your help Aristos!