Here is my code:
import time
from appium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
desired_caps = {
'platformName': 'Android',
'deviceName': 'Sony',
'appPackage': 'com.android.chrome',
'appActivity': 'com.google.android.apps.chrome.Main',
'chromeOptions': {'androidProcess': 'com.android.chrome:privileged'},
'automationName': 'UiAutomator2'
}
driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
driver.get('https://slotscity.ua/ru/registration')
accept_btn = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.ID, 'com.android.chrome:id/negative_button')))
accept_btn.click()
contexts = driver.contexts
for context in contexts:
print(context)
webview = driver.contexts[1]
driver.switch_to.context(webview)
print(driver.current_context)
time.sleep(5)
close_button = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, '/html/body/div[1]/div/div/div[1]/div[1]/div/div[2]/div/div[2]/input')))
time.sleep(5)
action_chains = ActionChains(driver)
action_chains.move_to_element(close_button).click().perform()
#close_button.click()
driver.quit()
All working until
close_button = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, ‘/html/body/div[1]/div/div/div[1]/div[1]/div/div[2]/div/div[2]/input’)))
Stacktrace:
/Users/squad/PycharmProjects/Test_Test_Prj_1/venv/bin/python /Users/squad/PycharmProjects/Test_Test_Prj_1/test_cases/test_slot_city_2.py
NATIVE_APP
WEBVIEW_chrome
WEBVIEW_chrome
Traceback (most recent call last):
File "/Users/squad/PycharmProjects/Test_Test_Prj_1/test_cases/test_slot_city_2.py", line 35, in <module>
close_button = WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, '/html/body/div[1]/div/div/div[1]/div[1]/div/div[2]/div/div[2]/input')))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/squad/PycharmProjects/Test_Test_Prj_1/venv/lib/python3.11/site-packages/selenium/webdriver/support/wait.py", line 95, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
Stacktrace:
0 chromedriver_mac64_v114.0.5735.90 0x00000001045226b8 chromedriver_mac64_v114.0.5735.90 + 4937400
1 chromedriver_mac64_v114.0.5735.90 0x0000000104519b73 chromedriver_mac64_v114.0.5735.90 + 4901747
2 chromedriver_mac64_v114.0.5735.90 0x00000001040d7616 chromedriver_mac64_v114.0.5735.90 + 435734
3 chromedriver_mac64_v114.0.5735.90 0x000000010411ae0f chromedriver_mac64_v114.0.5735.90 + 712207
4 chromedriver_mac64_v114.0.5735.90 0x000000010411b0a1 chromedriver_mac64_v114.0.5735.90 + 712865
5 chromedriver_mac64_v114.0.5735.90 0x000000010415c9a4 chromedriver_mac64_v114.0.5735.90 + 981412
6 chromedriver_mac64_v114.0.5735.90 0x000000010413f03d chromedriver_mac64_v114.0.5735.90 + 860221
7 chromedriver_mac64_v114.0.5735.90 0x0000000104159e76 chromedriver_mac64_v114.0.5735.90 + 970358
8 chromedriver_mac64_v114.0.5735.90 0x000000010413ede3 chromedriver_mac64_v114.0.5735.90 + 859619
9 chromedriver_mac64_v114.0.5735.90 0x000000010410cd7f chromedriver_mac64_v114.0.5735.90 + 654719
10 chromedriver_mac64_v114.0.5735.90 0x000000010410e0de chromedriver_mac64_v114.0.5735.90 + 659678
11 chromedriver_mac64_v114.0.5735.90 0x00000001044de2ad chromedriver_mac64_v114.0.5735.90 + 4657837
12 chromedriver_mac64_v114.0.5735.90 0x00000001044e3130 chromedriver_mac64_v114.0.5735.90 + 4677936
13 chromedriver_mac64_v114.0.5735.90 0x00000001044e9def chromedriver_mac64_v114.0.5735.90 + 4705775
14 chromedriver_mac64_v114.0.5735.90 0x00000001044e405a chromedriver_mac64_v114.0.5735.90 + 4681818
15 chromedriver_mac64_v114.0.5735.90 0x00000001044b692c chromedriver_mac64_v114.0.5735.90 + 4495660
16 chromedriver_mac64_v114.0.5735.90 0x0000000104501838 chromedriver_mac64_v114.0.5735.90 + 4802616
17 chromedriver_mac64_v114.0.5735.90 0x00000001045019b7 chromedriver_mac64_v114.0.5735.90 + 4802999
18 chromedriver_mac64_v114.0.5735.90 0x000000010451299f chromedriver_mac64_v114.0.5735.90 + 4872607
19 libsystem_pthread.dylib 0x00007ff8191dd4e1 _pthread_start + 125
20 libsystem_pthread.dylib 0x00007ff8191d8f6b thread_start + 15
Process finished with exit code 1
What can be wrong?