Skip to main content

Posts

Showing posts from May, 2018

Python - PyQt5 set Background image

import sys from PyQt5.QtCore import QSize from PyQt5.QtGui import QImage, QPalette, QBrush from PyQt5.QtWidgets import * class MainWindow ( QWidget ): def __init__ ( self ): QWidget. __init__ ( self ) self .setGeometry( 100 , 100 , 300 , 200 ) oImage = QImage( "test.jpg" ) sImage = oImage.scaled(QSize( 300 , 200 )) # resize Image to widgets size palette = QPalette() palette.setBrush( 10 , QBrush(sImage)) # 10 = Windowrole self .setPalette(palette) self .show() if __name__ == "__main__" : app = QApplication(sys.argv) oMainwindow = MainWindow() sys.exit(app.exec_())

VBA - Open Publisher

Sub OpenPub () 'Set reference to use Microsoft Publisher 'Use the Tools Menu and References 'Search down the list for Microsoft Publisher Dim pubApp As Publisher . Application Dim pubDoc As Publisher .Document Set pubApp = New Publisher. Application pubApp. Open ( "C:\Documents\Publisher Document Name.pub" ) 'pubApp.ActiveWindow.Visible = True pubApp.ActiveDocument.ExportAsFixedFormat pbFixedFormatTypePDF, "C:\Documents\PDF Document name.pdf" pubApp.Quit End Sub

VBA - IE automation get children element

Sub Contacts () On Error Resume Next Dim i As Long Dim IE As Object Dim objElement As Object Dim objCollection As Object ' Create InternetExplorer Object Set IE = CreateObject ( "InternetExplorer.Application" ) ' You can uncoment Next line To see form results IE. Visible = True ' Send the form data To URL As POST binary request Strt = ThisWorkbook. Sheets ( "Data" ). Cells (ThisWorkbook. Sheets ( "Data" ).Rows.Count, "C" ). End ( xlUp ).Row If Strt = 1 Then Strt = 2 End If For csk = Strt To ThisWorkbook. Sheets ( "Data" ).UsedRange.Rows.Count IE.Navigate ThisWorkbook. Sheets ( "Data" ). Cells ( csk , 2 ).Value ' Wait while IE loading... Do While IE.Busy Application .Wait Dat

VBA - IE automation in already opened webpage

Sub Manta () For csk = 1 To 99 ' Determine if a specific instance of IE is already open. Set objShell = CreateObject ( "Shell.Application" ) IE_count = objShell.Windows.Count For x = 0 To ( IE_count - 1 ) On Error Resume Next ' sometimes more web pages are counted than are open my_url = objShell. Windows ( x ).Document.Location my_title = objShell. Windows ( x ).Document.Title 'You can use my_title of my_url, whichever you want If my_url Like "https://www.manta.com" & "*" Then 'identify the existing web page Set IE = objShell. Windows ( x ) Exit For Else End If Next

Winium first test code in Internet Explorer

# coding: utf-8 from selenium import webdriver import time driver = webdriver.Remote( command_executor = 'http://localhost:9999' , desired_capabilities ={ "debugConnectToRunningApp" : 'false' , "app" : r "C: \\ Program Files \\ internet explorer \\ iexplore . exe" }) print ( 'started' ) time.sleep( 2 ) window = driver.find_element_by_name( 'Tools' ) window.click() print ( 'done' ) driver.close()

First Winium code

# coding: utf-8 from selenium import webdriver driver = webdriver.Remote( command_executor = 'http://localhost:9999' , desired_capabilities ={ "debugConnectToRunningApp" : 'false' , "app" : r "C:/windows/system32/calc . exe" }) window = driver.find_element_by_class_name( 'CalcFrame' ) view_menu_item = window.find_element_by_id( 'MenuBar' ).find_element_by_name( 'View' ) view_menu_item.click() view_menu_item.find_element_by_name( 'Scientific' ).click() view_menu_item.click() view_menu_item.find_element_by_name( 'History' ).click() window.find_element_by_id( '132' ).click() window.find_element_by_id( '93' ).click() window.find_element_by_id( '134' ).click() window.find_element_by_id( '97' ).click() window.find_element_by_id( '138' ).click() window.find_element_by_id( '121' ).click() driver.

Winium - Windows application automation [Java based and .Net based application]

Winium.Desktop is an open source test automation tool for automated testing of Windows application based on WinForms and WPF platforms. Requirements Microsoft .NET Framework 4.5.1 Quick Start Write your tests using you favorite language. In your tests use  app   desired capability  to set path to tested app's exe file. Here is python example: # put it in setUp self .driver = webdriver.Remote( command_executor = ' http://localhost:9999 ' , desired_capabilities = { ' app ' : ' C: \\ testApp.exe ' , ' args ' : ' -port 345 ' }) # put it in test method body win = self .driver.find_element_by_id( ' WpfTestApplicationMainWindow ' ) win.find_element_by_id( ' SetTextButton ' ).click() assert ' CARAMBA ' == self .driver.find_element_by_id( ' MyTextBox ' ).text Start  Winium.Desktop.Driver.exe  ( download re