Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    jazz198833
    @jazz198833
    hi. I want to update it by adding that method. But i dont understand how to make it work.
    Peter Nguyen Tr
    @PeterNgTr

    all right, maybe you can follow this path:

    • create your base that extends from seleniumbase: for instance, you name it base.py
    from selenium.webdriver.common.action_chains import ActionChains
    from seleniumbase import BaseCase
    
    class BaseTestCase(BaseCase):
         def push_tab(self):
               ActionChains(self.driver).send_keys(Keys.TAB).perform()

    Now in your test file

    from base import BaseTestCase
    
    class MyFeature(BaseTestCase):
    
        @pytest.mark.testrail('C1234')
        def test_search(self):
             self.open('https://www.google.com.ua/')
             self.push_tab()
    Peter Nguyen Tr
    @PeterNgTr
    Please format it. Kinda hard to read
    jazz198833
    @jazz198833
    Here i created new module base_new.py

    from selenium.webdriver.common.action_chains import ActionChains
    from selenium.webdriver.common.keys import Keys
    from seleniumbase import BaseCase

    class BaseTestCase(BaseCase):
    def push_tab(self):
    ActionChains(self.driver).send_keys(Keys.TAB).perform()
    self.push_tab()

    afterwards created test file basic_test.py

    from seleniumbase import BaseCase
    from seleniumbase.fixtures.base_new import BaseTestCase

    class Test(BaseCase,BaseTestCase):
    def test_search(self):
    self.open('https://www.google.com.ua/')
    self.push_tab()

    And when i'm running my test i'm getting import error
    ImportError while importing test module '/Users/niko/Downloads/SeleniumBase-master/examples/basic_test.py'.
    Hint: make sure your test modules/packages have valid Python names.
    Traceback:
    basic_test.py:2: in <module>
    from seleniumbase.fixtures.base_new import BaseTestCase
    E ModuleNotFoundError: No module named 'seleniumbase.fixtures.base_new'
    peekyIL
    @pattarika
    Anyone has sample to use seleniumbase with jenkins? I am building jenkinfiles and struggle with passing username and password.
    stage('Test') {
    withCredentials([[$class: 'UsernamePasswordMultiBinding',
    credentialsId: 'accessTokenToAzureRepo',
    usernameVariable: 'USERNAME',
    passwordVariable: 'PASSWORD']]) {
    dir("${env.WORKSPACE}/SharePoint"){
    script{
    sh ("""docker exec -t sp pytest \
    --browser=remote --server selenium-hub --port 4444 \
    --cap_file=capabilities/firefox.py --headless \
    --log_path=tests/latest_logs --save_screenshot \
    --data=X_SITE_1,education,${USERNAME},${PASSWORD} \
    --verbose -k verify""")
    }
    }
    }
    sorry i don't know how to format the syntax
    Michael Mintz
    @mdmintz
    Sy
    @symonk
    @mdmintz I think when trying to click an element that isnt there etc, latest_logs writing to the file system doesnt work
    I get no latest_log files written to when my tests fails with: selenium.common.exceptions.ElementNotVisibleException
    --save_screenshot does indeed work
    Sy
    @symonk
    has_exception looks to be False in this instance
    (pytest)
    Michael Mintz
    @mdmintz
    @symonk Try upgrading to the latest version of SeleniumBase and try again. It was working for me just now.
    Sy
    @symonk
    are you using pytest? i think its related to that @mdmintz
    has_exception in base case is False, even tho this exception occured
    Sy
    @symonk
    (Pdb) has_exception False (Pdb) self.save_screenshot_after_test False (Pdb) has_exception False (Pdb) self.with_testing_base True
    no files in latest_logs
    Michael Mintz
    @mintzworld_twitter
    I could not reproduce on my build. I’m using pytest. I have the SeleniumBase pytest.ini file at the base of my repo. Not sure if you made any modifications that would alter that functionality.
    Sy
    @symonk
    quite likely, will just check - we have made some recently :) (cut the inheritance)
    leaving work in 15, will make a repeatable gist (if its not me being dumb) and open an issue
    peekyIL
    @pattarika
    @mdmintz i was able to get credential from jenkins into pytest using seleniumbase, thanks!
    Peter Nguyen Tr
    @PeterNgTr
    maybe someone knows how to skip setup method for a certain test in a test file. Let's say we have a test file that has 5 tests, but we want to run setup for 4 tests and skip it for a test. Do you have any lights to achieve this? Many thanks!
    Michael Mintz
    @mintzworld_twitter
    @PeterNgTr To skip setUp(), don’t put that test in a class that inherits BaseCase. Although then you won’t have any SeleniumBase functionality in that class, if that’s what you’re looking for.
    Sy
    @symonk
    @mdmintz how can we disable --with-testing-base? we want to handle our own screenshots etc
    Michael Mintz
    @mdmintz
    @symonk You can reduce logging, but not eliminate all of it. Add --with-basic_test_info on the command line to get any stack traces in latest_logs/, but not the screenshot or page source.
    Sy
    @symonk
    @mdmintz I opened an issue, curious on your thoughts - if you like it i can implement it
    Michael Mintz
    @mintzworld_twitter
    @symonk I’m already working on solutions to that and the PDF Chinese character export issue. Updates are slow this week due to Thanksgiving travel. Coincidentally, 3 new GitHub issue requests in the last 2 days, at a very busy time.
    Michael Mintz
    @mdmintz
    v1.33.8 and v1.33.9 are released. That takes care of all currently open issues.
    normalPerson123
    @normalPerson123
    Hey, I'm pretty new to Python, but I did a bunch of Java WebDriver stuff for a few years at my job. This is knocking my socks off. Is there any way I or anyone else can help you?
    Michael Mintz
    @mdmintz
    @normalPerson123 Let me know if you run into any issues. I'm quick on resolving them.
    Also, please spread the word about SeleniumBase! It's not as popular as other test frameworks out there, but that doesn't mean it's not better than them.
    normalPerson123
    @normalPerson123
    I'm already doing a project with it for work.
    I will try to spread it around.
    Michael Mintz
    @mdmintz
    Just added mobile device testing in SeleniumBase v1.34.0 - https://github.com/seleniumbase/SeleniumBase/releases/tag/v1.34.0
    normalPerson123
    @normalPerson123
    Hey, I want to centralize my url's and have different ones per environment. I spent some time messing with conftest.py files and had a tough time getting the fixtures tk work with my suite class. I noticed BaseTestCase.py in examples/Boilerplates. Should I just be reading a config file in the setup method?
    I feel like you've thought of this and I'm missing some really obvious pattern.
    Michael Mintz
    @mdmintz
    Hi @normalPerson123 , you can accomplish that by parsing files. I have an example of that here: https://github.com/seleniumbase/SeleniumBase/tree/master/examples/boilerplates/file_parsing (see parse_files.py)
    You can use --env=qa to specify the qa environment, for example. (A separate feature)
    Built-in env options are qa, staging, production, develop, master, local, and test.
    If --env=ENV isn't enough, use --data=STRING to pass anything into the tests. Then use self.data to access that. (It's self.env to access the env variable during tests.)
    normalPerson123
    @normalPerson123
    Thanks!
    normalPerson123
    @normalPerson123
    I'm some trouble with typing in an input on an iframe. I can get it to work in one environment, but not another, so I decided to go with javascript execution, just document.getelementbyid("whatever").value = "something else" but that doesn't work in either env. Do I need to do anything other than switching iframes execute that javascript?
    normalPerson123
    @normalPerson123
    Nm. Nested iframe. Sorry