jeudi 31 octobre 2019

Cross browser testing in selenium with python

from selenium import webdriver as wd
import pytest
import time
Chrome=wd.Chrome(executable_path=r"C:\Chrome\chromedriver.exe")
Firefox=wd.Firefox(executable_path=r"C:\geckodriver\geckodriver.exe")
class TestLogin():
    @pytest.fixture()
    def setup1(self):
        browsers=[Chrome, Firefox]
        for i in browsers:
            self.driver= i
            i.get("https://www.python.org")
            time.sleep(3)

        yield
        time.sleep(3)
        self.driver.close()

    def test_Python_website(self,setup1):
        self.driver.find_element_by_id("downloads").click()
        time.sleep(3)

I am trying to run this code to perform some action in Chrome and Firefox browser. But when I run the program chrome browser starts and Test cases are not working in Chrome browser. then Firefox opens and test case works fine in Firefox. I tried for loop and couple of things didnt work. kindly someone help.

Aucun commentaire:

Enregistrer un commentaire