from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.common import exceptions
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.firefox.webdriver import FirefoxProfile
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
from selenium.webdriver.common.proxy import Proxy, ProxyType
from selenium.webdriver.firefox.service import Service
profile_path = "F:\\ea_env\\..................\\firefox_profile"
cookie_path = "F:\\ea_env\\..................\\firefox_cookie.pkl"
my_url = "https://kitchen.applitools.com/ingredients/canvas/"
profile_path = r"C:\Users\..................\Roaming\Mozilla\Firefox\Profiles\2jwvchja.bot5"
desktop_path = str(pathlib.Path.home()) + '\\Desktop'
gecko_path = f"{desktop_path}\\geckodriver.exe"
options = Options()
options.headless = False
options.set_preference('profile', profile_path)
service = Service(gecko_path)
options.add_argument('--no-first-run --no-service-autorun --password-store=basic')
options.add_argument('--excludeSwitches --enable-logging')
options.add_argument('--no-default-browser-check')
options.add_argument('--no-sandbox')
driver = webdriver.Firefox (service=service, options=options)
driver.implicitly_wait(100)
driver.set_page_load_timeout(100)
driver.get (my_url)
canvas = driver.find_element(By.ID, "burger_canvas")
action = ActionChains(driver)
action.move_to_element_with_offset(canvas, 500, 350).click().perform()
Description:
I followed tutorial below and tried to do it by Python Standalone Selenium.
https://www.youtube.com/watch?v=NebFQ31NFtE
target url for test:
https://kitchen.applitools.com/ingredients/canvas
I saved canvas picture and tried to find the center location of canvas's button (Lets Eat) via Paint.
x: 500px
y: 350px
https://imgur.com/a/kya1dji
Error:
Exception ignored in: <function Popen.__del__ at 0x0000013663B6E430>
Traceback (most recent call last):
File "C:\Python38\lib\subprocess.py", line 949, in __del__
self._internal_poll(_deadstate=_maxsize)
File "C:\Python38\lib\subprocess.py", line 1348, in _internal_poll
if _WaitForSingleObject(self._handle, 0) == _WAIT_OBJECT_0:
OSError: [WinError 6] The handle is invalid
even i tried code below:
canvas = self.driver.find_element(By.ID, "burger_canvas")
canvas_dimen = canvas.size
canvas_location = canvas.location
canvas_center_x = int(canvas_dimen.get('width') / 2)
canvas_center_y = int(canvas_dimen.get('height') / 2)
loc_x = int((canvas_center_x / 3) * 2)
loc_y = int((canvas_center_y / 3) * 2)
action = ActionChains(self.driver)
action.move_to_element_with_offset(canvas, loc_x, loc_y).click().perform()
Github:
https://github.com/SeleniumHQ/selenium/issues/10666