I'm writing test in TestCafe and I should check, that the field for typing is empty. I'm doing it using eql assertion
.expect(instanceQuery.resultField.value).eql('')
But I'm getting an error: AssertionError: expected ' ' to deeply equal ' '
When I copy/paste your error message in a console, I get empty space characters, and the eql assertion expects an empty string.
Sometimes it happens that when you copy stuff to/from the console you get different space characters. Make sure you type yourself the empty string.
You can try it out here: sandbox
Related
I'm using Option Strict On (and sometimes wishing I wasn't!) but have a piece of code that works as I want it to without it but not with it.
It should be quite simple I think but I couldn't find an answer here.
My code that works with Option Strict Off is this:
If returnedString.Contains(".exe ") And returnvalues.Count = 0 Then
Dim x As Integer = 0
For Each entry In returnedString.Split(".exe ")
If (entry.Length > 0) And x = 0 Then
returnvalues.Add(entry & ".exe")
x = x + 1
End If
Next
End If
The returnedString is, for example:
C:\Program Files (x86)\Whatever\Whatever.exe
and
C:\Program Files (x86)\Whatever\Whatever
is returned in entry if Option Strict is off, which is what I want.
However, if I use Visual Studio's suggestion of adding a cast, the following does not work:
For Each entry As String In returnedString.Split(CType(".exe ", Char()))
The first entry returned is C:\Program and this is presumably because it finds the Char ' '; I don't want it to check per character, I want it to check the whole string like it does when Option Strict is off but I can't work it out.
I tried .ToCharArray but that really does the same thing.
Please continue to use Option Strict On. It is annoying but it will save your day a lot.
For your problem:
It is caused by the fact that when you enable Option Strict On, the compiler is no longer allowed to take the first char from your string and use it as separator. Because there is no overload for string.Split that takes just a string, then it complains about an attempt to an do invalid conversion.
If you want to use a string as separator then it is required to pass an array of strings as the first parameter, and a second parameter of type StringSplitOptions is required.
Fixing it is really simple. Just change the line to:
For Each entry In returnedString.Split({".exe"}, StringSplitOptions.None)
I've created a C# dll using the web service wsdl.exe. Based on that I have create both a C# and VB.Net application, and they both retrieve the data I expect and give me the result.
The VBA code that calls the same external dll fails. The dll returns an object that has a property 'DataArea' that is an array of objects.
Dim response As CustomerPrice.SimulatePriceResponseType
Set response = New CustomerPrice.SimulatePriceResponseType
Set response = CustPriceService.SimulatePrice(st)
Dim bob As String
bob = response.DataArea(0).bookPrice_Value
In C# and VB.Net the last line gives the value required.
In VBA the last line indicates a 'Wrong Number of arguments or invalid property assignment'
In 'Immediate mode debugging'
Print response gives SimulatePriceResponseType as expected.
Print response.DataArea gives Type Mismatch (error 13)
Print response.DataArea(0) gives wrong number of arguments (error 450)
Any ideas what is happening and what I can do to fix it?
It seems that it has something to do with the array, or with how VBA is interpreting it, although I am not sure exactly what.
I found the dll source code and added a property that returned only the first element of the array as an PriceData object, not an PriceData[] array.
Works as it should
I am using closedXML to take a datatable and place this into an Excel file.
The code I am working with works, with 99% of the files I put through the application, but I get an error with a file every now and then. (no this is not a debugging issue)
The problem must originate from the data, however I am at a loss on how to resolve this.
The code I'm using is
Public Sub WriteToExcel(dt As DataTable, filePath As String)
Dim workbook = New XLWorkbook()
Dim worksheet = workbook.Worksheets.Add(dt, "Call Validate Export")
Try
workbook.SaveAs(filePath)
Process.Start(filePath)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End Sub
When saving the file I get the error
'', hexadecimal value 0x1A, is an invalid character.
between the '' there is a little arrow pointing to the right.
When reading the file in to the datatable it reads in fine, looking at the file I see no hex characters.
The file being read in is a ^ delimited csv file.
So, my question is how to I check and repair\replace the bad characters in the output that will allow me to save 100% of the time.
From the XML specification ( https://www.w3.org/TR/xml/#charsets )
Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD] | [#x10000-#x10FFFF] /* any Unicode character, excluding the surrogate blocks, FFFE, and FFFF. */
Which implies that character #x1A is an invalid character. You should manually remove it.
#Simon,
It looks like whatever you are trying to export to Excel, it contains some invalid characters (Arrow pointing to right side).
I was receiving the similar error and upon detailed look, I come to know that I am exporting DataTable into Excel and one of the cell value of DataTable was looking like:
Please Note -> Some comment (Here, -> is actually a single character : Arrow pointing to right side)
I have removed those characters and it is working fine now.
Hope this helps.
https://github.com/ClosedXML/ClosedXML/pull/66 is a pull request which could solve your issue. Please try it.
Str strTopLeftCellIdentifier = "Account No"
I just tracked down the cause of my code triggering the error handler. it was that line not updating the value of strtopleftcellidentifier. Obviously, the first Str isn't meant to be there.
Yet, it will run that line.
I'm aware that Str() is a VBA function, but even with that, I don't understand how it's interpreting that line in any intelligible way.
What does the macro think it's doing and/or why isn't it causing an error?
Because Str() is a valid function name in VBA. So your statement is actually comparing strTopLeftCellIdentifier to "Account No" and passing the boolean result to Str(). It's the equivalent of:
Str False
And since you're not capturing the return value of Str(), parentheses are not required when making the call.
The paragraph object in the Word has a property called Range. Within this Range object has a property called Cells.
For paragraph that are not in a table, this property Paragraph.Range.Cells is set to "". This can be seen in the Watches window in debug mode.
For paragraph that are in a table, the property Paragraph.Range.Cells has other properties in it, for example it has a property called Count.
I am using this property of Paragraph.Range.Cells to determine if the paragraph is in a table or not. However, I cant seem to figure out how to test this.
For example, I cannot simply test like this...
If paragraph.Range.Cells <> Null Then.... or even
If IsNull(paragraph.Range.Cells) Then ...
It throws a Run-time error '5907' There is no table at this location
So, how would I test for this? thanks
You can use the Information property:
If Selection.Information(wdWithInTable) Then
'What ever you'd like to do
End If
Hence you don't need any manual error catching mechanisms.
You can't call the Cells method unless the paragraph is in a table. You need to use a different method to determine whether the range is in a table.
You can use either...
paragraph.Range.Tables.Count > 0
...or...
paragraph.Range.Information(wdWithinTable)
Note that the second one looks more obvious, but is actually slower (only a problem if you're doing this inside a loop).
*Edited (if Err=) changed to (If Err<>)
You can simply allow the error to happen and catch it using OnError statement
Dim ParagraphIsTable As Object
OnError Resume Next 'allows errors to happen but execute next instruction
ParagraphIsTable = paragraph.Range.Cells
If Err <> 5907 Then '(this is to check for a specific error that might have happened)
'No Error occured, this means that ParagraphIsTable variable must contain a value
' Do the rest of your code here
Else
' an Error occured, this means that this is not a table
' do whatever
End If
OnError Goto 0 ' This cancels the effect of OnError Resume Next
' Which means if new errors happen, you will be prompt about them