selene icon indicating copy to clipboard operation
selene copied to clipboard

Add example of how to «hard-wait» (sleep) before any waiting command in Selene

Open yashaka opened this issue 3 years ago • 6 comments

... to slow it down and be more like real user;)

Provide example for pre_pause_in_wait decorator for confi._wait_decorator similar to the existing example: https://github.com/yashaka/selene/blob/master/examples/log_all_selene_commands_with_wait.py

There are some extra explanations with amost done receipt in this telegram message (in russian, but the translation should be obvious, Google Translate bless you!🙏🏻)

yashaka avatar Sep 27 '22 13:09 yashaka

@yashaka I would like to take this up. As this will be my first contribution to this repo. if you can guide me it will be very helpful.

deepgohil avatar Dec 04 '22 17:12 deepgohil

@deepgohil I would like to help you with this, but taking into account lack of time - faster would be to do it on my own. I still can help, but not in the way "giving direct guided tasks what to do". The original message already has some hints where to start. If you have a few questions to clarify something - with this I can help. But to guide fully through corresponding implementation - for this I don't have time.

Maybe somebody other will help you, some other more experienced contributor.

Or just wait for the task that already has more complete guide...

yashaka avatar Dec 06 '22 10:12 yashaka

related to #456 #459

yashaka avatar Dec 06 '22 10:12 yashaka

@yashaka correct me if I am wrong, but we would need to create an example similar to the one you have mentioned but instead of logging decorator would be pausing/waiting to mimic human behavior. if yes please assign this issue to me. Thanks

vaibhavsahni009 avatar Apr 02 '23 20:04 vaibhavsahni009

@vaibhavsahni009, yes, just similar to example I show, but with some sleep instead of logging.

If in the original example we had:

@pytest.fixture(scope='function', autouse=True)
def browser_management():
    SeleneFormatter.translations = (
        ('browser.element', 'element'),
        ('browser.all', 'all'),
        ("'css selector', ", ""),
        (r"('\ue007',)", "Enter"),
        ('((', '('),
        ('))', ')'),
        (': has ', ': have '),
        (': have ', ': should have '),
        (': is ', ': should be'),
    )
    browser.config._wait_decorator = log_on_wait

    yield

in the new example we should have something like:

@pytest.fixture(scope='function', autouse=True)
def browser_management():
    browser.config._wait_decorator = sleep_before_wait_starts(seconds=1.0)

    yield
    

yashaka avatar Apr 03 '23 09:04 yashaka