I am using pytest needle for testing purpose.In conftest.py I have created a fixture which have scope="class". In this fixture I am creating a browser instance using needle.driver and using request object I am trying to use it in other test classes.
This is for Python 3.7.4 , needle version 0.3.11 , pytest version 4.6.5.
#content of conftest.py
import pytest
@pytest.fixture(scope="class")
def setup(needle , request):
needle.driver.get('https://www.google.com')
request.cls.driver=needle.driver
---------------------------------------------------------------
#content of test_case1.py
from selenium.webdriver.common.by import By
from selenium import webdriver
import os
from selenium.webdriver.common.keys import Keys
import pytest
import unittest
@pytest.mark.usefixtures("setup")
class test(unittest.TestCase):
def test_example_element(self):
self.driver.find_element_by_name("q").send_keys("Selenium")
self.driver.assert_screenshot('D:\\Screenshot\\XPYgdg', (By.NAME, 'q'))
When I run test_case1.py with command py.test --driver Chrome test_case1.py , I get following error :
ScopeMismatch: You tried to access the 'function' scoped fixture 'needle' with a 'class' scoped request object, involved factories
conftest.py:3: def setup(needle, request)