Forum Discussion
tristaanogre
13 years agoEsteemed Contributor
Here's how that VBS stuff code would work, translated to JScript in TestComplete (posted, BTW, on the SQAForums thread you started on this topic... it's helpful if you keep conversations on a single source to make it easier to know what has been discussed already)
function PrintersListing(){
var WScriptObj = Sys.OleObject("WScript.Network")
var PrintersCollection = WScriptObj.EnumPrinterConnections()
var Index
for (Index=0;Index<PrintersCollection.length;Index += 2)
{
Log.Message("Port " + PrintersCollection.Item(Index) + " = " + PrintersCollection.Item(Index+1))
}
}
To do the comparison that you want, it would be a matter of changing the Log.Message call to a comparison call. I haven't tested this part yet but I assume it would look something like this.function CheckPrinterExists(PrinterName){
var WScriptObj = Sys.OleObject("WScript.Network")
var PrintersCollection = WScriptObj.EnumPrinterConnections()
var Index
for (Index=0;Index<PrintersCollection.length;Index += 2)
{
if (PrintersCollection.Item(Index+1) == PrinterName)
return true
}
Log.Warning("Printer " + PrinterName + " not found in windows installation")
return false
}
Related Content
- 6 years agocmbdnne
- 8 years agom_essaid
- 5 years agodjvakarjoshi1
- 2 months agoStoplight
Recent Discussions
- 18 hours agovladd1