-
Notifications
You must be signed in to change notification settings - Fork 1
/
__main__.py
57 lines (37 loc) · 1.49 KB
/
__main__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Copyright 2022 Appdiff Inc.
"""A brief example demonstrating the basic capabilities of test.ai enhanced Selenium."""
__author__ = ('[email protected] (Alexander Wu)')
__copyright__ = 'Copyright 2022 Appdiff Inc.'
import logging
import sys
from time import sleep
from test_ai.test_ai import TestAiDriver
from selenium.webdriver import Chrome
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
def _main() -> None:
"""Main driver"""
# log = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO)
chrome_driver = Chrome(service=Service(ChromeDriverManager().install()))
driver = TestAiDriver(chrome_driver, sys.argv[1])
# Navigate to the target website
driver.get("https://testaistore.com/")
sleep(2)
# Find and interact with elements
accessories_nav_link = driver.find_element_by_id("menu-item-671", "accessories_nav_link")
accessories_nav_link.click()
sleep(2)
anchor_bracelet = driver.find_element_by_xpath('//*[@id="main"]/div/ul/li[1]/div[1]/a', "anchor_bracelet")
anchor_bracelet.click()
sleep(2)
add_to_cart = driver.find_element_by_xpath('//*[@id="product-2707"]/div[2]/form/button', "add_to_cart")
add_to_cart.click()
sleep(2)
view_cart = driver.find_element_by_css_selector("#main > div > div.woocommerce-notices-wrapper > div > a", "view_cart")
view_cart.click()
# Done
sleep(5)
driver.quit()
if __name__ == "__main__":
_main()