From d1b008efbf4ce0fd8b2c3aff1a15f855f62baf29 Mon Sep 17 00:00:00 2001 From: piyush-browserstack Date: Sun, 29 Dec 2024 13:26:17 +0530 Subject: [PATCH 01/16] My changes 1 --- .DS_Store | Bin 0 -> 6148 bytes browserstack.yml | 75 +++++++------------------------- tests/selenium-local-testing.py | 67 ++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+), 60 deletions(-) create mode 100644 .DS_Store create mode 100644 tests/selenium-local-testing.py diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..51227d71a94e52683c4d00d01ac912a7dfa75f3b GIT binary patch literal 6148 zcmeHKI|>3p3{CuiU}I@HSMUad=n3`$7K)81_^Y?_TprDrPoXS!S|~4&yqQeiEc=Sh zMnrUeSOjyq1*=D6P-_S;VFyM%Fva+Zyp5TE&WLZbpy zfC^9nDnJE3tw46z(fHFB^FAs-1%6%u`#u!7VNGlU{nLTqBLHxKv>VnwO8|={fHkoV zL$0gG>bW2DSK<@<*e5h_zG?{ceokWPC@W?4D@!4jkV*c7e!sMHO^~d U8|ZZ8oet#BfayY`0^e5P0W;M1& literal 0 HcmV?d00001 diff --git a/browserstack.yml b/browserstack.yml index d698962..fb7967d 100644 --- a/browserstack.yml +++ b/browserstack.yml @@ -1,63 +1,18 @@ -# ============================= -# Set BrowserStack Credentials -# ============================= -# Add your BrowserStack userName and accessKey here or set BROWSERSTACK_USERNAME and -# BROWSERSTACK_ACCESS_KEY as env variables -userName: YOUR_USERNAME -accessKey: YOUR_ACCESS_KEY - -# ====================== -# BrowserStack Reporting -# ====================== -# The following capabilities are used to set up reporting on BrowserStack: -# Set 'projectName' to the name of your project. Example, Marketing Website -projectName: BrowserStack Samples -# Set `buildName` as the name of the job / testsuite being run -buildName: browserstack build -# `buildIdentifier` is a unique id to differentiate every execution that gets appended to -# buildName. Choose your buildIdentifier format from the available expressions: -# ${BUILD_NUMBER} (Default): Generates an incremental counter with every execution -# ${DATE_TIME}: Generates a Timestamp with every execution. Eg. 05-Nov-19:30 -# Read more about buildIdentifiers here -> https://www.browserstack.com/docs/automate/selenium/organize-tests -buildIdentifier: '#${BUILD_NUMBER}' # Supports strings along with either/both ${expression} - -# ======================================= -# Platforms (Browsers / Devices to test) -# ======================================= -# Platforms object contains all the browser / device combinations you want to test on. -# Entire list available here -> (https://www.browserstack.com/list-of-browsers-and-platforms/automate) +userName: piyushhatwalne_0KJM5f +accessKey: xxxBWyxhJ1UNwurUzHvVZxW platforms: - - os: OS X - osVersion: Big Sur - browserName: Chrome - browserVersion: latest - os: Windows osVersion: 10 - browserName: Edge - browserVersion: latest - - deviceName: Samsung Galaxy S22 Ultra - browserName: chrome # Try 'samsung' for Samsung browser - osVersion: 12.0 - -# ========================================== -# BrowserStack Local -# (For localhost, staging/private websites) -# ========================================== -# Set browserStackLocal to true if your website under test is not accessible publicly over the internet -# Learn more about how BrowserStack Local works here -> https://www.browserstack.com/docs/automate/selenium/local-testing-introduction -browserstackLocal: true # (Default false) -# browserStackLocalOptions: -# Options to be passed to BrowserStack local in-case of advanced configurations - # localIdentifier: # (Default: null) Needed if you need to run multiple instances of local. - # forceLocal: true # (Default: false) Set to true if you need to resolve all your traffic via BrowserStack Local tunnel. - # Entire list of arguments available here -> https://www.browserstack.com/docs/automate/selenium/manage-incoming-connections - -source: python-browserstack:sample-sdk:v1.0 - -# =================== -# Debugging features -# =================== -debug: false # # Set to true if you need screenshots for every selenium command ran -networkLogs: false # Set to true to enable HAR logs capturing -consoleLogs: errors # Remote browser's console debug levels to be printed (Default: errors) -# Available options are `disable`, `errors`, `warnings`, `info`, `verbose` (Default: errors) + browserName: Chrome + browserVersion: 120.0 + - os: OS X + osVersion: Monterey + browserName: Safari + browserVersion: 15.6 + - deviceName: iPhone 13 + osVersion: 15 + browserName: Chromium + deviceOrientation: portrait +browserstackLocal: true +buildName: browserstack-build-1 +projectName: BrowserStack Sample \ No newline at end of file diff --git a/tests/selenium-local-testing.py b/tests/selenium-local-testing.py new file mode 100644 index 0000000..45ee613 --- /dev/null +++ b/tests/selenium-local-testing.py @@ -0,0 +1,67 @@ +from selenium import webdriver +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.common.by import By +from selenium.common.exceptions import NoSuchElementException, TimeoutException + +def run_test(driver): + """Function to execute the test""" + try: + # Open the target website + driver.get('https://bstackdemo.com/') + + # Wait for the page title to contain 'StackDemo' + WebDriverWait(driver, 10).until(EC.title_contains('StackDemo')) + + # Get the text of the product - iPhone 12 + item_on_page = WebDriverWait(driver, 10).until( + EC.visibility_of_element_located((By.XPATH, '//*[@id="1"]/p')) + ).text + + # Click the 'Add to cart' button if it is visible + WebDriverWait(driver, 10).until( + EC.visibility_of_element_located((By.XPATH, '//*[@id="1"]/div[4]')) + ).click() + + # Check if the Cart pane is visible + WebDriverWait(driver, 10).until( + EC.visibility_of_element_located((By.CLASS_NAME, 'float-cart__content')) + ) + + # Get the text of the product in the cart + item_in_cart = WebDriverWait(driver, 10).until( + EC.visibility_of_element_located((By.XPATH, '//*[@id="__next"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]')) + ).text + + # Verify whether the product (iPhone 12) is added to the cart + if item_on_page == item_in_cart: + print(f"Test Passed: iPhone 12 successfully added to cart on {driver.name}!") + else: + print(f"Test Failed: iPhone 12 not added to cart on {driver.name}!") + except NoSuchElementException as e: + print(f"Test Failed on {driver.name}: Element not found - {e}") + except TimeoutException as e: + print(f"Test Failed on {driver.name}: Operation timed out - {e}") + except Exception as e: + print(f"Test Failed on {driver.name}: An unexpected error occurred - {e}") + finally: + # Stop the driver + driver.quit() + +# Run on Chrome +chrome_driver = webdriver.Chrome() # Ensure ChromeDriver is installed and in PATH +print("Running test on Chrome...") +run_test(chrome_driver) + +# Run on Safari +try: + safari_driver = webdriver.Safari() # SafariDriver is pre-installed on macOS + print("Running test on Safari...") + run_test(safari_driver) +except Exception as e: + print(f"Safari test could not run: {e}") + +# Run on Firefox +firefox_driver = webdriver.Firefox() # Ensure GeckoDriver is installed and in PATH +print("Running test on Firefox...") +run_test(firefox_driver) \ No newline at end of file From a1b315674b9e3ee325dd3822d4dfa533fadf347c Mon Sep 17 00:00:00 2001 From: piyush-browserstack Date: Sun, 29 Dec 2024 14:39:36 +0530 Subject: [PATCH 02/16] change 2 --- requirements.txt | 1 + .../pytest-local.cpython-313-pytest-8.3.4.pyc | Bin 0 -> 4643 bytes .../test_local.cpython-313-pytest-8.3.4.pyc | Bin 0 -> 4641 bytes tests/test_local.py | 61 ++++++++++++++++++ 4 files changed, 62 insertions(+) create mode 100644 tests/__pycache__/pytest-local.cpython-313-pytest-8.3.4.pyc create mode 100644 tests/__pycache__/test_local.cpython-313-pytest-8.3.4.pyc create mode 100644 tests/test_local.py diff --git a/requirements.txt b/requirements.txt index 6bb0568..338c4ba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ browserstack-local >= 1.2.3 selenium browserstack-sdk +pytest diff --git a/tests/__pycache__/pytest-local.cpython-313-pytest-8.3.4.pyc b/tests/__pycache__/pytest-local.cpython-313-pytest-8.3.4.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c39a506dac12365d89c64ebd159182b55b9d48ac GIT binary patch literal 4643 zcmcf_OKcm*b(TLZDT)#$SyF7v8Bwt;#-eC_Y{zmXSa#&tlqI=b(U!{^#FAW!TP=6# z*`+NJ3EH?RTo(nBivgbs_mmh2(DYOv(^K7~hn1LA!9qp?v_RpT3;B>Hm%iEMl9DaM zt>Jbd?R)e7`{vEe8*Vl=`4Bv(*(-~EjR^gX4(!KWMK*r}$SuSnj+sV;F`*;oR2>+_ zT*Qqnj)!=Fvknr@8wNt21YrvtHO(rn_M>6TcK1Y@nF6{8<} z;(fOBIt-yG;u?O)a4hFN=HPt0(cvnSv~!KS5!toKg#8aGZ8ppp-fKcSOT?=JfkD$n zA^oN~xX6nd5ZZ+0qL9&qY$~J3Sy2-eSp~A=n%IA0@8f>m4XQ&z&^b~o*7gWQoW)yJC)ISQj z0PltW%`-slMHmvCK=CaCHp($$3kdNY2qhghEl#zcctW+b$jn^!8MYid*z!DK2!`8i zO+3Sva|c`Ob8K}bp~$Rb1Q=JNMRBF1=JV0>CX6U@TH#4nloumep`b)HPz9kC3L}z|;ibXi z3hAT~(-)0jEyL>}`WbrUL2UDlciw&HHd|@H8^PV{!Jf5XPbJuU)ANDs&i0=LjUTH{++0kG)9G4_mOl%(?JlYs5yaJA;+ z_GV-=0VZpe8{e_+IHzsZhA(K{+# zdg5I+R)-Vr(W?j|^GtdcgBHv& z$zj{#OYqn6ANU)6iT*mD?=OeOov$J|^SjCe^KdZI10R|`F}H&GEIm6hkBdafmNF)b zp7|M`XoKa>yrvb^v1l}{YJ6sip0I-%r4W5cH&w&SQR16GEC-^|*OMp2?09G>bU9iq zw{06|#jDBD%jLG5r0`mVnoiN4QiIO1JW-QOrDS1Q19cF$|C7V!a66#PKR9HxoZs16$Qf6E*Wdk zTZ1@62ArNTJP9otJ$;IHPtey9+Bz8Sh4Yj1XAGAHQ)IX^l9*XCe5cM$ za$IV5a%Rf#ov?bY6ip>RFEQV+f%knkeR|u#7i{FQ2YEX_$lXp? z*q(Lvz$$y-W5;^`v9ujuT#s-S|NLXB1x}t9-Lf88srbuJMEA&tTK29sA6#ei*54YN|K;1Yk%fG@ zjkdaNWJ&y$&EKwTfy9;(Sp4Xx_ujrI-=EQcl+!OQ>XE9inj3Ji!8YkFQ=jJkwDiZN zPcQ3nP7lm~$tJ$tXzbZUjC+>Zfca|tRpSTBo!o~@zg@a>Ssy-gKX~7%x1U>QXI9yn z?>8FvP|@={iN@{^-S5@gXV=-eRdxgjJ03CgRPCP&dzeaO#Np!F` l_Fdn%)_LUKPga?;|8)47)=ejJ#F$4Wx_3Wwi6JpC^KXix+~EKK literal 0 HcmV?d00001 diff --git a/tests/__pycache__/test_local.cpython-313-pytest-8.3.4.pyc b/tests/__pycache__/test_local.cpython-313-pytest-8.3.4.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2be13799feb62fc4f6ad59d6da9d3f1092926218 GIT binary patch literal 4641 zcmcf_OKcm*b(TLZDT)#$SyF7v8Bwt;MxtnaY{yC^Sa#&vlqI=b(U!{^#FAW!TP=6# z*`+NJ3EH?RTo(nBivgbs_tY2&(DYOv(^K7~hn1LA!9qp?v_RpT3;B>Hm%iEMl9DaM zt>Jbd?Yw#aee>qc8*Vi<`4Bv(*(*zZjR^gXPVC2B1-5<-z%9ffj+sG(F-J$tsX8!< zxriHE6c6zL#WB+mV+m{GoHO2-kN8a3HPaaLlO_{(&je!4q}hZ$GcB%(!?B$AxP$ZUMMtVc(#|#RMP$zs6ZSu(xVbQ6c&`cRED^5?1SU-v zh4fqIfM^p|ib6&cvZ;(BXGKj^WEIekldEBe(J`lRrA&TW5(O|N8xB4sdI z7Q}*}l!s6*dWJ@FCxTuAe402xHy%5;tAElA~W;ZXXtY5qRaDyBAD*b zHTeu(&Ruk|&(YPDge0>b&b7PV02*~1sYXg*63kU}3sNk>#G7o%`e-KtMoaEv&Kwi= zl!s4?D_V&NSW~bl!vgb?SQaoZXK_Xnco~<9Sj!8zmKa0C3knI{2823S-jk5kQn9EI z$P%0;$~9FW<9IIIV7SfYBu?NmJg2Jbf7)Ju&RT!p1zsu%(}XC*a9t@u);Wv@B3vm6 zs%Chs%v9-0Vr(3bCP29wEsCopHJ^{3H^+z~rxl)LMR_Tb6$(mJ15wp{rz9oAOGCv~ z(n| z&is7#Un)(Z>nHKa5VIr48vsp%wRHg)ZlMD-!?*7NAkl|o?DfVdN%_qu0mbAc-!)f`*v74Q0KFu5Y$FH$86us z)1vMhwt4I0cBy%W^Kp$Y-K*LT_^-UGNr6|5oPWp>fqgE!wnaKr{|Xy|NH-;z0OA4( z2b>=+J04tf1X#G1gzGS4>TxFz+A`ZT_Sv}l2=Q^-TI^9^xS;GzhHWmc73$gR_N+dF zA8n(x>H}v}um>dvZF&RZ55pIEl0!Bo4)Z4;_@ee_YTuLaZ2wA(UPa)UXUek_w8k8h z9I-XN1bZF-fxWSpXs`46_Ht;#`6_}FzpFgB0LLRe?xE!qbE}xo(vuVOxJZ<2DPxl8 ziJ#$#HdOA+Yg$nqk4Dp~#%Gr4`8t$Q3ektOs2X05BHsdJIS`G$o;)FDCql!a%h6)F zZO1$-UQLc&F1O_*h1Vifb&7VB8uX3j$r@)WB?~JWhy%O*pByo#I|oWkj)Ixw@Z~V` ztz%*$%#>RX_7_(VhgCc=fhjl=Rt>+X35Ap*r;7ZNP@Rc#iaG#&h7J#GSBa3fJx};RdTq>;^QUCx_8UeYT7aTNBHX(e0BX1|z6cJGLG| zk2a&l3Pm=X(iAh@$RwaCNj(l-8nm9SUiT&DYc}w{@1{?08~mJ&JoX@O#|OFF=?dGk z!5&&;4}Ij==s&*RfBfD+rT_Hj?Dv7A>)@RWAI2-4hc`Npu5}*W^anQlgX{jmkJ7)( z-_7f9oY5m^EB@G))6wPohc9sRwMTB`-SgP@r0S;xXZ6Tj#Xk>%UJz`)dGJ?j*; z9_RGH!WV4fo6W|aEyTFzm`zx(#$Psmpxnv*cKJ8UcP{HAXYL2@JN5Q+8|>^FJNw;c z<37rIemBsr@sPlswhBMen=w0FGX-)RXXn@G{I-2)&1X*7N`!cz}*QKqnrcfv?a!ToN7ZjRV&Y ital#0_v1C@>^~iTrgh7S95LpR3GP40Tw+KJ)chNt!rUkT literal 0 HcmV?d00001 diff --git a/tests/test_local.py b/tests/test_local.py new file mode 100644 index 0000000..2a69896 --- /dev/null +++ b/tests/test_local.py @@ -0,0 +1,61 @@ +import pytest +from selenium import webdriver +from selenium.webdriver.support.ui import WebDriverWait +from selenium.webdriver.support import expected_conditions as EC +from selenium.webdriver.common.by import By +from selenium.common.exceptions import NoSuchElementException, TimeoutException + +# Define a pytest fixture for the WebDriver setup and teardown +@pytest.fixture(params=["chrome", "firefox", "safari"], scope="function") +def driver(request): + """Fixture to initialize and clean up the WebDriver.""" + if request.param == "chrome": + driver = webdriver.Chrome() # Ensure ChromeDriver is installed and in PATH + elif request.param == "firefox": + driver = webdriver.Firefox() # Ensure GeckoDriver is installed and in PATH + elif request.param == "safari": + driver = webdriver.Safari() # SafariDriver is pre-installed on macOS + else: + raise ValueError(f"Unsupported browser: {request.param}") + + yield driver # This provides the driver instance to the test + driver.quit() # Quit the driver after the test completes + +def test_add_to_cart(driver): + """Test to verify adding a product to the cart.""" + try: + # Open the target website + driver.get('https://bstackdemo.com/') + + # Wait for the page title to contain 'StackDemo' + WebDriverWait(driver, 10).until(EC.title_contains('StackDemo')) + + # Get the text of the product - iPhone 12 + item_on_page = WebDriverWait(driver, 10).until( + EC.visibility_of_element_located((By.XPATH, '//*[@id="1"]/p')) + ).text + + # Click the 'Add to cart' button if it is visible + WebDriverWait(driver, 10).until( + EC.visibility_of_element_located((By.XPATH, '//*[@id="1"]/div[4]')) + ).click() + + # Check if the Cart pane is visible + WebDriverWait(driver, 10).until( + EC.visibility_of_element_located((By.CLASS_NAME, 'float-cart__content')) + ) + + # Get the text of the product in the cart + item_in_cart = WebDriverWait(driver, 10).until( + EC.visibility_of_element_located((By.XPATH, '//*[@id="__next"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]')) + ).text + + # Verify whether the product (iPhone 12) is added to the cart + assert item_on_page == item_in_cart, f"Expected item: {item_on_page}, but found: {item_in_cart}" + print(f"Test Passed: iPhone 12 successfully added to cart on {driver.name}!") + except NoSuchElementException as e: + pytest.fail(f"Test Failed on {driver.name}: Element not found - {e}") + except TimeoutException as e: + pytest.fail(f"Test Failed on {driver.name}: Operation timed out - {e}") + except Exception as e: + pytest.fail(f"Test Failed on {driver.name}: An unexpected error occurred - {e}") \ No newline at end of file From b71675bd8e72428544768ba949a4ebf4ff100317 Mon Sep 17 00:00:00 2001 From: piyush-browserstack Date: Sun, 29 Dec 2024 14:44:33 +0530 Subject: [PATCH 03/16] ad --- tests/test_local.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/test_local.py b/tests/test_local.py index 2a69896..f775f96 100644 --- a/tests/test_local.py +++ b/tests/test_local.py @@ -28,7 +28,7 @@ def test_add_to_cart(driver): driver.get('https://bstackdemo.com/') # Wait for the page title to contain 'StackDemo' - WebDriverWait(driver, 10).until(EC.title_contains('StackDemo')) + WebDriverWait(driver, 30).until(EC.title_contains('StackDemo')) # Get the text of the product - iPhone 12 item_on_page = WebDriverWait(driver, 10).until( @@ -36,17 +36,17 @@ def test_add_to_cart(driver): ).text # Click the 'Add to cart' button if it is visible - WebDriverWait(driver, 10).until( + WebDriverWait(driver, 30).until( EC.visibility_of_element_located((By.XPATH, '//*[@id="1"]/div[4]')) ).click() # Check if the Cart pane is visible - WebDriverWait(driver, 10).until( + WebDriverWait(driver, 30).until( EC.visibility_of_element_located((By.CLASS_NAME, 'float-cart__content')) ) # Get the text of the product in the cart - item_in_cart = WebDriverWait(driver, 10).until( + item_in_cart = WebDriverWait(driver, 30).until( EC.visibility_of_element_located((By.XPATH, '//*[@id="__next"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]')) ).text From 666d209c5c3ea54cffa51f06a6e53ed8f510404c Mon Sep 17 00:00:00 2001 From: piyush-browserstack Date: Sun, 29 Dec 2024 20:13:10 +0530 Subject: [PATCH 04/16] srwf --- .env | 2 ++ browserstack.err | 1 + browserstack.yml => browserstack_template.yml | 4 ++-- configBSfile.py | 19 +++++++++++++++++++ requirements.txt | 1 + tests/test.py | 3 +++ 6 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 .env create mode 100644 browserstack.err rename browserstack.yml => browserstack_template.yml (83%) create mode 100644 configBSfile.py diff --git a/.env b/.env new file mode 100644 index 0000000..b319077 --- /dev/null +++ b/.env @@ -0,0 +1,2 @@ +BROWSERSTACK_USERNAME=piyushhatwalne_0KJM5f +BROWSERSTACK_ACCESS_KEY=BWyxhJ1UNwurUzHvVZxW \ No newline at end of file diff --git a/browserstack.err b/browserstack.err new file mode 100644 index 0000000..a6e1414 --- /dev/null +++ b/browserstack.err @@ -0,0 +1 @@ +[object Object] \ No newline at end of file diff --git a/browserstack.yml b/browserstack_template.yml similarity index 83% rename from browserstack.yml rename to browserstack_template.yml index fb7967d..5300d86 100644 --- a/browserstack.yml +++ b/browserstack_template.yml @@ -1,5 +1,5 @@ -userName: piyushhatwalne_0KJM5f -accessKey: xxxBWyxhJ1UNwurUzHvVZxW +userName: ${BROWSERSTACK_USERNAME} +accessKey: ${BROWSERSTACK_ACCESS_KEY} platforms: - os: Windows osVersion: 10 diff --git a/configBSfile.py b/configBSfile.py new file mode 100644 index 0000000..ef1d166 --- /dev/null +++ b/configBSfile.py @@ -0,0 +1,19 @@ +import os +from dotenv import load_dotenv + +# Load environment variables +load_dotenv() + +# Read the YAML file as a string +with open("browserstack_template.yml", "r") as file: + content = file.read() + +# Replace placeholders with environment variables +content = content.replace("${BROWSERSTACK_USERNAME}", os.getenv("BROWSERSTACK_USERNAME", "")) +content = content.replace("${BROWSERSTACK_ACCESS_KEY}", os.getenv("BROWSERSTACK_ACCESS_KEY", "")) + +# Write the updated YAML back to a file or use it directly +with open("browserstack.yml", "w") as file: + file.write(content) + +print("Updated browserstack.yml written to browserstack_resolved.yml") \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 338c4ba..6621c7a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ browserstack-local >= 1.2.3 selenium browserstack-sdk pytest +python-dotenv diff --git a/tests/test.py b/tests/test.py index c242b14..d16fd6c 100644 --- a/tests/test.py +++ b/tests/test.py @@ -6,6 +6,9 @@ from selenium.common.exceptions import NoSuchElementException from selenium.webdriver.chrome.options import Options as ChromeOptions + + + # The webdriver management will be handled by the browserstack-sdk # so this will be overridden and tests will run browserstack - # without any changes to the test files! From ce1100468d8bc4867476150907efb23b29073668 Mon Sep 17 00:00:00 2001 From: piyush-browserstack Date: Sun, 29 Dec 2024 23:01:09 +0530 Subject: [PATCH 05/16] werwer --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0f2dc0c..e4cd1ae 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,2 @@ /local.log -env +.env From 027520d9f774f7cdbbebfc1515650fc0096cccea Mon Sep 17 00:00:00 2001 From: piyush-browserstack Date: Sun, 29 Dec 2024 23:02:01 +0530 Subject: [PATCH 06/16] Delete .env --- .env | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 .env diff --git a/.env b/.env deleted file mode 100644 index b319077..0000000 --- a/.env +++ /dev/null @@ -1,2 +0,0 @@ -BROWSERSTACK_USERNAME=piyushhatwalne_0KJM5f -BROWSERSTACK_ACCESS_KEY=BWyxhJ1UNwurUzHvVZxW \ No newline at end of file From 061d518cdf6b5c374341a65507ed36ffc8048c98 Mon Sep 17 00:00:00 2001 From: piyush-browserstack Date: Mon, 30 Dec 2024 00:49:32 +0530 Subject: [PATCH 07/16] mn --- browserstack_template.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/browserstack_template.yml b/browserstack_template.yml index 5300d86..d5435d5 100644 --- a/browserstack_template.yml +++ b/browserstack_template.yml @@ -15,4 +15,7 @@ platforms: deviceOrientation: portrait browserstackLocal: true buildName: browserstack-build-1 -projectName: BrowserStack Sample \ No newline at end of file +projectName: BrowserStack Sample +percy: true +percyCaptureMode: auto + From 75808ddcf0c150662b59fbaefd5e00b030336259 Mon Sep 17 00:00:00 2001 From: piyush-browserstack Date: Mon, 30 Dec 2024 16:22:04 +0530 Subject: [PATCH 08/16] Update browserstack_template.yml --- browserstack_template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browserstack_template.yml b/browserstack_template.yml index d5435d5..0b2e3f0 100644 --- a/browserstack_template.yml +++ b/browserstack_template.yml @@ -18,4 +18,4 @@ buildName: browserstack-build-1 projectName: BrowserStack Sample percy: true percyCaptureMode: auto - +accessibility: true From f22c0c08a3e23dc1b989b881fd8362e5dd19315b Mon Sep 17 00:00:00 2001 From: piyush-browserstack Date: Mon, 30 Dec 2024 17:02:59 +0530 Subject: [PATCH 09/16] Update browserstack_template.yml --- browserstack_template.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/browserstack_template.yml b/browserstack_template.yml index 0b2e3f0..ad6ab75 100644 --- a/browserstack_template.yml +++ b/browserstack_template.yml @@ -5,14 +5,6 @@ platforms: osVersion: 10 browserName: Chrome browserVersion: 120.0 - - os: OS X - osVersion: Monterey - browserName: Safari - browserVersion: 15.6 - - deviceName: iPhone 13 - osVersion: 15 - browserName: Chromium - deviceOrientation: portrait browserstackLocal: true buildName: browserstack-build-1 projectName: BrowserStack Sample From 809f18f98f1ceed38bc476247a05dd3593a05f08 Mon Sep 17 00:00:00 2001 From: piyush-browserstack Date: Mon, 30 Dec 2024 17:17:36 +0530 Subject: [PATCH 10/16] Update browserstack_template.yml --- browserstack_template.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/browserstack_template.yml b/browserstack_template.yml index ad6ab75..9ab3dbc 100644 --- a/browserstack_template.yml +++ b/browserstack_template.yml @@ -1,5 +1,6 @@ userName: ${BROWSERSTACK_USERNAME} accessKey: ${BROWSERSTACK_ACCESS_KEY} +framework: pytest platforms: - os: Windows osVersion: 10 From 1307d78d1cdf86fa71a8bd9244215940586e24fc Mon Sep 17 00:00:00 2001 From: piyush-browserstack Date: Tue, 31 Dec 2024 14:10:40 +0530 Subject: [PATCH 11/16] Update browserstack_template.yml --- browserstack_template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browserstack_template.yml b/browserstack_template.yml index 9ab3dbc..25693c8 100644 --- a/browserstack_template.yml +++ b/browserstack_template.yml @@ -8,7 +8,7 @@ platforms: browserVersion: 120.0 browserstackLocal: true buildName: browserstack-build-1 -projectName: BrowserStack Sample +projectName: Piyush-onboarding-percy-test percy: true percyCaptureMode: auto accessibility: true From 375d740f594196875b95eb77bfbb0ed8f216bd69 Mon Sep 17 00:00:00 2001 From: piyush-browserstack Date: Tue, 31 Dec 2024 14:52:41 +0530 Subject: [PATCH 12/16] Update test_local.py --- tests/test_local.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_local.py b/tests/test_local.py index f775f96..3d22755 100644 --- a/tests/test_local.py +++ b/tests/test_local.py @@ -29,7 +29,7 @@ def test_add_to_cart(driver): # Wait for the page title to contain 'StackDemo' WebDriverWait(driver, 30).until(EC.title_contains('StackDemo')) - + PercySDK.screenshot(driver, "page1") # Get the text of the product - iPhone 12 item_on_page = WebDriverWait(driver, 10).until( EC.visibility_of_element_located((By.XPATH, '//*[@id="1"]/p')) @@ -44,7 +44,7 @@ def test_add_to_cart(driver): WebDriverWait(driver, 30).until( EC.visibility_of_element_located((By.CLASS_NAME, 'float-cart__content')) ) - + PercySDK.screenshot(driver, "page2") # Get the text of the product in the cart item_in_cart = WebDriverWait(driver, 30).until( EC.visibility_of_element_located((By.XPATH, '//*[@id="__next"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]')) @@ -58,4 +58,4 @@ def test_add_to_cart(driver): except TimeoutException as e: pytest.fail(f"Test Failed on {driver.name}: Operation timed out - {e}") except Exception as e: - pytest.fail(f"Test Failed on {driver.name}: An unexpected error occurred - {e}") \ No newline at end of file + pytest.fail(f"Test Failed on {driver.name}: An unexpected error occurred - {e}") From 1586503dc441da4fe3886bc21df7b2467d49ecdf Mon Sep 17 00:00:00 2001 From: piyush-browserstack Date: Tue, 31 Dec 2024 14:56:58 +0530 Subject: [PATCH 13/16] Update test_local.py --- tests/test_local.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_local.py b/tests/test_local.py index 3d22755..6006eb7 100644 --- a/tests/test_local.py +++ b/tests/test_local.py @@ -4,6 +4,7 @@ from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from selenium.common.exceptions import NoSuchElementException, TimeoutException +from percy import percy_snapshot # Define a pytest fixture for the WebDriver setup and teardown @pytest.fixture(params=["chrome", "firefox", "safari"], scope="function") @@ -29,7 +30,7 @@ def test_add_to_cart(driver): # Wait for the page title to contain 'StackDemo' WebDriverWait(driver, 30).until(EC.title_contains('StackDemo')) - PercySDK.screenshot(driver, "page1") + percy_snapshot(driver, 'page1') # Get the text of the product - iPhone 12 item_on_page = WebDriverWait(driver, 10).until( EC.visibility_of_element_located((By.XPATH, '//*[@id="1"]/p')) @@ -44,7 +45,7 @@ def test_add_to_cart(driver): WebDriverWait(driver, 30).until( EC.visibility_of_element_located((By.CLASS_NAME, 'float-cart__content')) ) - PercySDK.screenshot(driver, "page2") + percy_snapshot(driver, 'page2') # Get the text of the product in the cart item_in_cart = WebDriverWait(driver, 30).until( EC.visibility_of_element_located((By.XPATH, '//*[@id="__next"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]')) From 9de1f0b90293cbadc8300c04a889a38a8f9cf61f Mon Sep 17 00:00:00 2001 From: piyush-browserstack Date: Tue, 31 Dec 2024 14:58:56 +0530 Subject: [PATCH 14/16] Update requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 6621c7a..bd59701 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ selenium browserstack-sdk pytest python-dotenv +percy-selenium From ca31d024a4592db38f42cd0ab80cb040876d9dbe Mon Sep 17 00:00:00 2001 From: piyush-browserstack Date: Tue, 31 Dec 2024 15:24:41 +0530 Subject: [PATCH 15/16] Update browserstack_template.yml --- browserstack_template.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/browserstack_template.yml b/browserstack_template.yml index 25693c8..7e917ce 100644 --- a/browserstack_template.yml +++ b/browserstack_template.yml @@ -8,7 +8,7 @@ platforms: browserVersion: 120.0 browserstackLocal: true buildName: browserstack-build-1 -projectName: Piyush-onboarding-percy-test +projectName: Piyush-onboarding-31 percy: true percyCaptureMode: auto accessibility: true From ab16a5860205ccb312e54375f9a88d6ba994ff92 Mon Sep 17 00:00:00 2001 From: piyush-browserstack Date: Tue, 31 Dec 2024 15:25:11 +0530 Subject: [PATCH 16/16] Update test_local.py --- tests/test_local.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/tests/test_local.py b/tests/test_local.py index 6006eb7..d8ffd69 100644 --- a/tests/test_local.py +++ b/tests/test_local.py @@ -4,7 +4,6 @@ from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from selenium.common.exceptions import NoSuchElementException, TimeoutException -from percy import percy_snapshot # Define a pytest fixture for the WebDriver setup and teardown @pytest.fixture(params=["chrome", "firefox", "safari"], scope="function") @@ -30,7 +29,6 @@ def test_add_to_cart(driver): # Wait for the page title to contain 'StackDemo' WebDriverWait(driver, 30).until(EC.title_contains('StackDemo')) - percy_snapshot(driver, 'page1') # Get the text of the product - iPhone 12 item_on_page = WebDriverWait(driver, 10).until( EC.visibility_of_element_located((By.XPATH, '//*[@id="1"]/p')) @@ -45,7 +43,6 @@ def test_add_to_cart(driver): WebDriverWait(driver, 30).until( EC.visibility_of_element_located((By.CLASS_NAME, 'float-cart__content')) ) - percy_snapshot(driver, 'page2') # Get the text of the product in the cart item_in_cart = WebDriverWait(driver, 30).until( EC.visibility_of_element_located((By.XPATH, '//*[@id="__next"]/div/div/div[2]/div[2]/div[2]/div/div[3]/p[1]'))