I am relatively new to WatiN, but I would have thought the following line would have worked:
WebBrowser.Current.Table("grid").FindRow(value, columnNum).WaitUntilExists();
Currently it fails with the following exception:
System.NullReferenceException: Object reference not set to an instance of an object.
I am guessing it has to do with the fact that the row in question has not been populated when the tet runs, and hence FindRow returns a null.
I have replaced the line with:
while (WebBrowser.Current.Table("grid").FindRow(value, columnNum) == null){}
which works - but would prefer to use a WatiN in built method (with a timeout).
Any ideas as to how to fix my first line of code? Thanks!
Well, WaitUntilExits() is different than WaitUntilIsNotNull ( which isn't a method :D )
You can probably use
WebBrowser.Current.Table("grid").FindRow(value, columnNum).WaitForComplete()
or
WebBrowser.Current.Table("grid").FindRow(value, columnNum).WaitUntilExists()
or
WebBrowser.Current.Table("grid").FindRow(value, columnNum).WaitUntil(attribute, value)
depending on what you need
Related
Right so essentially I am creating a user interface and have attempted to add a QtWidgets.QLineEdit to a QVBoxLayout as well as a QtWidgets.QLabel to a different QVBoxLayout. Unfortunately it is not working and throwing up an error:
in build_gui_adddata_device
self.labellayout.addWidget(self.labelsupplierid)
TypeError: QBoxLayout.addwidget(QWidget; int stretch=0, Qt.Alignment alignment=0): first argument of unbound = method must have type QBoxLayout
I have defined labellayout as thus:
print("e")
self.labellayout = QtWidgets.QVBoxLayout
"e" was printed, which is how I know that there is no issue with the definition of the layout itself.
Just for reference this is the QtWidget I was trying to add:
print("f")
self.labelsupplierid = QtWidgets.QLabel("Supplier ID: ")
Again "f" was printed
This is the line that is causing the problem:
print("i")
self.labellayout.addWidget(self.labelsupplierid)
I don't understand why my code isn't working, I am honestly perplexed. My syntax seems to be correct and I have made other build_gui functions that have executed exactly the same type of code (with different widgets, might I add) that have been successful.
Please can someone enlighten me. Many Thanks.
I spent a long time now trying to figure this myself with the help of other questions but failed so I REALLY need to ask this again
I have the following object in ruby
(...)
:follow_request_sent:
:notifications:
:coordinates:
:place:
:contributors:
:favorite_count: 0
:entities:
:hashtags:
- :text:
:indices:
(...)
This is object X. What I want to do is check if x.place exists. I've tried barely EVERYTHING. any, ?, include?, with [hash], defined?, (...) but it ALWAYS throws an error "undefined method" when trying to access the property, whether it exists or not. It NEVER works and I don't understand why. This is twitter API btw. Does anyone imagine why? Please do not point me to another answers because basically they all failed.
If you want to see if there is such a method:
x.respond_to?(:place)
If you want to see if there is an instance variable:
x.instance_variable_defined?(:#place)
So I have a little lua script where I want to call an extension method on IEnumerable collection.
require ''CLRPackage''
import ''System.Collections.Generic''
import ''System.Linq''
import ''My.Namespace.Containing.AudioMarker''
local audioMarkersWithOffset = GetAudioMarkers();
local numberOfMarkers = audioMarkersWithOffset.Count();
So GetAudioMarkers() is a C# method returning an IEnumerable of AudioMarker objects. Doing a luanet.each will work fine and I will be able to iterate to every element of the collection. But I need the count of that collection and calling .Count() does the following error:
NLua.Exceptions.LuaScriptException: [string "chunk"]:54: attempt to call field 'Count' (a string value).
By the way, I know that with nlua you don't need to pre-register your types to used them so I try with and without the last import about AudioMarker, but got the same result.
I'm probably doing something wrong but I cannot seem to find any documentation on the web that could help regarding this issue.
I have been trying to use the IEnumerable<T>.ToList() extension method myself, but testing reveals that NLua has some problems with generic methods.. Calling a method of the form void func<T>(<T> arg) is possible if you register it as a lua function (Lua.RegisterFunction), but if you try to call the same method on an object present in lua state, you get the "attempt to call method..." error. Also, a method of the form void func<T>(IEnumerable<T> arg) will fail in both cases with a NullReferenceException and the "attempt to call method..." error, respectively.
Another point is, if you want to call C# extension methods from Lua, you need the ":" syntax, not "." (see the NLua "TestExtensionMethods" unit test).
Does anyone have the faintest idea what this error means please and how to resolve it? All my research is drawing a blank, I can see how to set it on MSDN but it doesn't explain it in a way that explains to me what the issue is. If I remove some of my LINQ queries to set viewbag items then it seems to resolve it but the moment I set new ones and pass them into my view to generate a mail for MVCMailer it comes back. Not sure if its a viewbag issue or simply that I am calling too many linq queries to generate them to pass to the view.
I am very stuck (again)..........
Cheers,
Steve.
DbLimitExpression requires a collection argument.
Parameter name: argument
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: DbLimitExpression requires a collection argument.
Parameter name: argument
An example of the code is:
var VBSalutation = from A in context.Salutations
where A.SalutationId == policytransaction.SalutationId
select A.SalutationName;
ViewBag.Salutation = VBSalutation.FirstOrDefault();
This is repeated for various parameters and then passed to the view.
Well, I faced a similar problem and solved it. Problem was in WHERE clause: data type of left side equal operator (=) sign was not matching with data type of right side. So in your scenario:
where A.SalutationId == policytransaction.SalutationId
SalutationID of A might be an INT and SalutationId of policytransaction might be a string (This is how it was in my case).
I solved it by assigning policytransaction.SalutationId to an Int variable and using it:
int myIntVariable = Convert.ToInt16(policytransaction.SalutationId);
...//some code here
where A.SalutationId == myIntVariable;
Please also note that you cannot directly cast your variables directly in Linq else you'll get an error "LINQ to Entities does not recognize the method". You'll have to use a temp variable and then apply the where clause.
Try ViewBag.Salutation = VBSalutation.SingleOrDefault();
I'd like to somehow find out which CFC is calling my method.
I have a logging CFC which is called by many different CFC's. On this logging CFC there's a need to store which CFC called for the log.
Whilst I could simply pass the CFC name as an argument to my log.cfc, I find this to be a repetitive task, that might not be necessary, if I somehow could find out "who's" calling the method on log.cfc
Is there any programmatic way of achieving this?
Thanks in advance
Update: As Richard Tingle's answer points out, since CF10 you can use CallStackGet(), which is better than throwing a dummy exception.
Original answer: The easiest way is to throw a dummy exception and immediately catch it. But this has the downside of making a dummy exception show up in your debug output. For me, this was a deal-breaker, so I wrote the following code (based off of this code on cflib). I wanted to create an object that is similar to a cfcatch object, so that I could use it in places that expected a cfcatch object.
Note: You may have to adjust this code a bit to make it work in CF8 or earlier. I don't think the {...} syntax for creating object was supported prior to CF9.
StackTrace = {
Type= 'StackTrace',
Detail= '',
Message= 'This is not a real exception. It is only used to generate debugging information.',
TagContext= ArrayNew(1)
};
j = CreateObject("java","java.lang.Thread").currentThread().getStackTrace();
for (i=1; i LTE ArrayLen(j); i++)
{
if(REFindNoCase("\.cf[cm]$", j[i].getFileName())) {
ArrayAppend(StackTrace.TagContext, {
Line= j[i].getLineNumber(),
Column= 0,
Template= j[i].getFileName()
});
}
}
From ColdFusion 10 there is now a function to do this callStackGet()
For example the following code will dump the stack trace to D:/web/cfdump.txt
<cfdump var="#callStackGet()#" output="D:/web/cfdump.txt">
One kludgey way is to throw/catch a custom error and parse the stack trace. Here are some examples
http://www.bennadel.com/blog/406-Determining-Which-Function-Called-This-Function-Using-ColdFusion-.htm
http://coldfusion.dzone.com/news/what-function-called-my-functi
I don't know of a method to do directly what you are asking, maybe someone else does.
However, I believe you could get the stack trace and create a function to parse the last method call.
This function on cflib will get you the stack trace.