I'm trying to launch a page with Browsers.Item(btChrome).Run(datavalue) and check if the page contains a specific word string that I'm looking for. And I got an error of Object required: 'Browsers'. I'm confused because I was following the tutorial of https://support.smartbear.com/testcomplete/docs/app-testing/web/general/examples/checking-specific-text.html. Can someone please point out where my code goes wrong?
Sub Test(datavalue)
Dim browser, page, str, Obj
Browsers.Item(btChrome).Run(datavalue) 'datavalue is an url
Set browser = Sys.Browser("*")
Set page = browser.Page("*")
str = "*Dashboard*"
If browser.ObjectIdentifier = "chrome" Then
Call aqObject.CheckProperty(body, "innerText", cmpContains, str, False)
Else
Call aqObject.CheckProperty(body, "textContent", cmpContains, str, False)
End If
End Sub
Related
Thanks for reading.
I have built a VB6 DLL (VB_InterFace just for a name) that talks to a C# DLL (C#_Driver just for a name) that talks to a Bluetooth Device.
The Demo VB6 test app (VB_Demo just for a name) I created as stage one works fine, does what it is supposed to. It calls the VB_Interface and Opens and Closes the BTDevice. Additional functions also work fine.
However on placing the operational code from VB_Interface into another DLL that is the live operations DLL, Open works fine, but Close is throwing an error. "Variable not defined" when returning from the C#_Driver.
I just can't see why, the code is the same, the process is only marginally different. By this I mean ;
In the VB_Demo I have two buttons "Open" "Close" and when I click on these I get the feedback that I expect from the BTDevice.
Private Sub btnOpenPort_Click()
'MsgBox steps(0)
ReDim steps(5)
Dim rc As HF4000_ResultCodes
'rc = driver.OpenSerial(cmbPorts.Text)
If driver.OpenSerial(cmbPorts.Text) = True Then
Private Sub btnClosePort_Click()
Dim rc As HF4000_ResultCodes
If driver.CloseSerial("COM4") = True Then
However in the live DLL it just executes the same functions internally without being initiated by a button click.
' See IScanDevice documentation.
' #see IScanDevice#OpenDevice
Private Function IScanDevice_OpenDevice() As Scanning.Scan_ResultCodes
(truncated slightly)
50 If driver.OpenSerial("COM4") = True Then
rc = READY
MsgBox "Connected to the device successfully."
' See IScanDevice documentation.
' #see IScanDevice#CloseDevice
Private Function IScanDevice_CloseDevice() As Scanning.Scan_ResultCodes
(truncated slightly)
50 If driver.CloseSerial("COM4") = True Then
60 rc = READY
70 IScanDevice_CloseDevice = Scan_Success
clsDriver.cls
Public Event OnStateChanged(newState As String)
Public Event OnDataUpdated()
Dim WithEvents CSharpInteropServiceEvents As CSharpInteropService.LibraryInvoke
Dim load As New LibraryInvoke
Private Sub Class_Initialize()
Set CSharpInteropServiceEvents = load
End Sub
Private Sub CSharpInteropServiceEvents_MessageEvent(ByVal newState As String)
If newState = "OpenForm1" Then
' FormDummy2.Show ' Not required
End If
If State <> newState Then
State = newState
RaiseEvent OnStateChanged(State)
GetDriverData
End If
End Sub
Private Function BluetoothTestInvoke(load, functionName, param)
BluetoothTestInvoke = load.GenericInvoke("BluetoothTest.dll", "BluetoothTest.Class1", functionName, param)
End Function
Function OpenSerial(portNumber) ' "COM4"
Dim param(0) As Variant
Dim retorno As Variant
param(0) = portNumber
retorno = BluetoothTestInvoke(load, "OpenSerial", param)
OpenSerial = retorno(0) <<<<<<< Works fine returns TRUE
End Function
Function CloseSerial(portNumber) ' "COM4"
Dim param(0) As Variant
Dim retorno As Variant
param(0) = portNumber
retorno = BluetoothTestInvoke(load, "CloseSerial", param)
CloseSerial = retorno(0) <<<<<<<<< "Error Subscript Out of Range"
End Function
What I have discovered is this - and I guess this is the reason why the Close is not working. The question is why is this situation occurring ...
When driver.OpenSerial executes, it hits > Function OpenSerial
Within Function OpenSerial it executes BluetoothTestInvoke where "load" is "CSharpInteropService.LibraryInvoke"
From there it moves to - Sub CSharpInteropServiceEvents_MessageEvent
.. and everything is fine.
However when I then execute driver.CloseSerial after that, it hits > Function CloseSerial
Within Function OpenSerial it executes BluetoothTestInvoke where "load" is "CSharpInteropService.LibraryInvoke"
Now here it "should" move to - Sub CSharpInteropServiceEvents_MessageEvent
However No, it just drops to the next line which is CloseSerial = retorno(0)
and this is where I get the "Subscript out of range" error for retorno(0)
For some reason in the CloseSerial it is not invoking "load"
BluetoothTestInvoke(load, "CloseSerial", param)
Thoughts and suggestions much appreciated.
UPDATE
Quite right, one should never assume anything.
On the tips I started digging deeper into the C# Library. It turns out the "param" value that is the Bluetooth port is passed into the CloseSerial call, and from there is is passed around within the external C# library dll. At one stage it is reset so the port number that should be handled is lost, thus it doesn't close but specifically the "expected" data was not returned to the calling app.
param(0) = portNumber
retorno = BluetoothTestInvoke(load, "CloseSerial", param) << param was being reset in the external library.
What I am doing wrong?
Public Function getRecords(query As String) As Adodc
With Adodc1
.RecordSource = query
.Refresh
End With
getRecords = Adodc1
End Function
Getting an error in line getRecords = Adodc1 where it shows nothing or Error 91.
The Code is written in a form consisting Adodc1 Control for ADODC object.
Got Solution by Rob :
set getRecords = Adodc1
We have noticed that sometimes from the results of an AJAX call to a controller action that the case of the JSON result is incorrect. The returned case will actually change if we rebuild our solution and try the exact same call. In the following case, the key's case has been correct for over a year until now when it has decided to start randomly changing depending on some seemingly random circumstances.
As you can see in the picture above, the key for the JSON result is lowercase "success". However when I view the results in Chrome's console, it is an uppercase "Success". This is causing our JavaScript to fail since it is checking for the lowercase version.
What is causing this? And more importantly, how do we stop this?
vb.net is case-insensitive as opposed to C# which is case-sensitive. This means that the compiler will generate only one class (from the first instance) for each of the following anonymous types:
Dim a = New With {.success = True} 'Compiler generate a class based on this type
Dim b = New With {.Success = True} 'Same type as `a`
Dim c = New With {.sUcCeSs = True} 'Same type as `a`
Debug.WriteLine(a.GetType().Name)
Debug.WriteLine(b.GetType().Name)
Debug.WriteLine(c.GetType().Name)
VB$AnonymousType_0'1
VB$AnonymousType_0'1
VB$AnonymousType_0'1
Here's how the complied code looks like when compiled back to vb.net:
<DebuggerDisplay("success={success}"), CompilerGenerated> _
Friend NotInheritable Class VB$AnonymousType_0(Of T0)
' Methods
<DebuggerNonUserCode> _
Public Sub New(ByVal success As T0)
Me.$success = success
End Sub
<DebuggerNonUserCode> _
Public Overrides Function ToString() As String
Dim builder As New StringBuilder
builder.Append("{ ")
builder.AppendFormat("{0} = {1} ", "success", Me.$success)
builder.Append("}")
Return builder.ToString
End Function
Public Property success As T0
<DebuggerNonUserCode> _
Get
Return Me.$success
End Get
<DebuggerNonUserCode> _
Set(ByVal Value As T0)
Me.$success = Value
End Set
End Property
Private $success As T0
End Class
How to strip ALL HTML tags using MSHTML Parser in VB6?
This is adapted from Code over at CodeGuru. Many Many thanks to the original author:
http://www.codeguru.com/vb/vb_internet/html/article.php/c4815
Check the original source if you need to download your HTML from the web. E.g.:
Set objDocument = objMSHTML.createDocumentFromUrl("http://google.com", vbNullString)
I don't need to download the HTML stub from the web - I already had my stub in memory. So the original source didn't quite apply to me. My main goal is just to have a qualified DOM Parser strip the HTML from the User generated content for me. Some would say, "Why not just use some RegEx to strip the HTML?" Good luck with that!
Add a reference to: Microsoft HTML Object Library
This is the same HTML Parser that runs Internet Explorer (IE) - Let the heckling begin. Well, Heckle away...
Here's the code I used:
Dim objDocument As MSHTML.HTMLDocument
Set objDocument = New MSHTML.HTMLDocument
'NOTE: txtSource is an instance of a simple TextBox object
objDocument.body.innerHTML = "<p>Hello World!</p> <p>Hello Jason!</p> <br/>Hello Bob!"
txtSource.Text = objDocument.body.innerText
The resulting text in txtSource.Text is my User's Content stripped of all HTML. Clean and maintainable - No Cthulhu Way for me.
One way:
Function strip(html As String) As String
With CreateObject("htmlfile")
.Open
.write html
.Close
strip = .body.outerText
End With
End Function
For
?strip("<strong>hello <i>wor<u>ld</u>!</strong><foo> 1234")
hello world! 1234
Public Function ParseHtml(ByVal str As String) As String
Dim Ret As String, TagOpenend As Boolean, TagClosed As Boolean
Dim n As Long, sChar As String
For n = 1 To Len(str)
sChar = Mid(str, n, 1)
Select Case sChar
Case "<"
TagOpenend = True
Case ">"
TagClosed = True
TagOpenend = False
Case Else
If TagOpenend = False Then
Ret = Ret & sChar
End If
End Select
Next
ParseHtml = Ret
End Function
This is a simple function i mafe for my own use.
use Debug window
?ParseHtml( "< div >test< /div >" )
test
I hope this will help without using external libraries
How to strip ALL HTML tags using MSHTML Parser in VB6?
This is adapted from Code over at CodeGuru. Many Many thanks to the original author:
http://www.codeguru.com/vb/vb_internet/html/article.php/c4815
Check the original source if you need to download your HTML from the web. E.g.:
Set objDocument = objMSHTML.createDocumentFromUrl("http://google.com", vbNullString)
I don't need to download the HTML stub from the web - I already had my stub in memory. So the original source didn't quite apply to me. My main goal is just to have a qualified DOM Parser strip the HTML from the User generated content for me. Some would say, "Why not just use some RegEx to strip the HTML?" Good luck with that!
Add a reference to: Microsoft HTML Object Library
This is the same HTML Parser that runs Internet Explorer (IE) - Let the heckling begin. Well, Heckle away...
Here's the code I used:
Dim objDocument As MSHTML.HTMLDocument
Set objDocument = New MSHTML.HTMLDocument
'NOTE: txtSource is an instance of a simple TextBox object
objDocument.body.innerHTML = "<p>Hello World!</p> <p>Hello Jason!</p> <br/>Hello Bob!"
txtSource.Text = objDocument.body.innerText
The resulting text in txtSource.Text is my User's Content stripped of all HTML. Clean and maintainable - No Cthulhu Way for me.
One way:
Function strip(html As String) As String
With CreateObject("htmlfile")
.Open
.write html
.Close
strip = .body.outerText
End With
End Function
For
?strip("<strong>hello <i>wor<u>ld</u>!</strong><foo> 1234")
hello world! 1234
Public Function ParseHtml(ByVal str As String) As String
Dim Ret As String, TagOpenend As Boolean, TagClosed As Boolean
Dim n As Long, sChar As String
For n = 1 To Len(str)
sChar = Mid(str, n, 1)
Select Case sChar
Case "<"
TagOpenend = True
Case ">"
TagClosed = True
TagOpenend = False
Case Else
If TagOpenend = False Then
Ret = Ret & sChar
End If
End Select
Next
ParseHtml = Ret
End Function
This is a simple function i mafe for my own use.
use Debug window
?ParseHtml( "< div >test< /div >" )
test
I hope this will help without using external libraries