Skip to main content

Posts

Showing posts from April, 2018

Python - PyQT5 integrated Selenium

import sys import os import time import msvcrt from PyQt5.QtWidgets import QApplication, QWidget, QLabel, QPushButton, QComboBox, QLineEdit from PyQt5.QtGui import QIcon from PyQt5.QtCore import * from PyQt5.QtGui import QPainter, QColor, QPen from PyQt5.QtCore import Qt from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.common.exceptions import TimeoutException from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.by import By import selenium.webdriver.support.ui as ui from selenium.webdriver.support.ui import WebDriverWait import selenium.webdriver.support.expected_conditions as EC class App ( QWidget ): m_blnLooping = True options = webdriver.ChromeOptions() options.add_argument( '--ignore-certificate-errors' ) options.add_argument( '--ignore-ssl-errors' ) dir_path = os.path.dirname(os

Python Selenium move_to_element does not always mouse-hover

from selenium import webdriver from selenium . webdriver . common . action_chains import ActionChains from selenium . webdriver . common . by import By from selenium . webdriver . support . ui import WebDriverWait from selenium . webdriver . support import expected_conditions as EC driver = webdriver . Chrome () driver . get ( "http://www.flipkart.com/watches/pr?p%5B%5D=facets.ideal_for%255B%255D%3DMen&p%5B%5D=sort%3Dpopularity&sid=r18&facetOrder%5B%5D=ideal_for&otracker=ch_vn_watches_men_nav_catergorylinks_0_AllBrands" ) driver . maximize_window () # wait for Men menu to appear, then hover it men_menu = WebDriverWait ( driver , 10 ). until ( EC . visibility_of_element_located (( By . XPATH , "//a[@data-tracking-id='men']" ))) ActionChains ( driver ). move_to_element ( men_menu ). perform () # wait for Fastrack menu item to appear, then click it fastrack = WebDriverWait ( driver , 10 ). until ( EC . visibility_