Skip to main content

Selenium Chrome Automation for windows 10 machine

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.common.by import By
import selenium.webdriver.support.ui as ui
import selenium.webdriver.support.expected_conditions as EC
import os
import time

options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')
dir_path = os.path.dirname(os.path.realpath(__file__))
chromedriver = dir_path + "/chromedriver"
print('dir_path')
os.environ["webdriver.chrome.driver"] = chromedriver
driver = webdriver.Chrome(chrome_options=options, executable_path= chromedriver)
time.sleep(1)
driver.get("https:\\www.google.com")
driver.close

Comments

Popular posts from this blog

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_())

pymsgbox - python package for message box

#This tutorial for to get a confirmation from the user by promting window #Python package "pymsgbox" needs to be install before run this below code #To install "pymsgbox" package go to command prompt and type in "PIP3 INSTALL pymsgbox" import pymsgbox #Displays a message box with OK and Cancel buttons. Number and text of buttons can be customized. Returns the text of the button clicked on. replyV = pymsgbox.confirm( text = 'Please login your application and click on on okay' , title = 'Login Confirmation' , buttons =[ 'OK' , 'Cancel' ]) print (replyV) #Displays a simple message box with text and a single OK button. Returns the text of the button clicked on. replyV = pymsgbox.alert( text = '' , title = '' , button = 'OK' ) print (replyV) #Displays a message box with text input, and OK & Cancel buttons. Returns the text entered, or None if Cancel was clicked. replyV1 = pyms...

VBA - UI Automation Sample code:

VBA Reference to be added: VBA - UI Automation Project sample code Dim MyElement As UIAutomationClient.IUIAutomationElement Dim MyElement1 As UIAutomationClient.IUIAutomationElement 'Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Public Enum oConditions    eUIA_NamePropertyId    eUIA_AutomationIdPropertyId    eUIA_ClassNamePropertyId    eUIA_LocalizedControlTypePropertyId End Enum Sub Test() Dim AppObj As UIAutomationClient.IUIAutomationElement Dim oInvokePattern As UIAutomationClient.IUIAutomationInvokePattern Dim oAutomation As New CUIAutomation ' the UI Automation API\ Dim oPattern As UIAutomationClient.IUIAutomationLegacyIAccessiblePattern Set AppObj = WalkEnabledElements("BTB Portal 3.0 KA") Set MyElement = AppObj.FindFirst(TreeScope_Children, PropCon...