Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibly unintended pause #37

Open
basvdl97 opened this issue Jan 11, 2023 · 2 comments
Open

Possibly unintended pause #37

basvdl97 opened this issue Jan 11, 2023 · 2 comments

Comments

@basvdl97
Copy link
Contributor

Here is an overview of two function in selenium_actions.py. I believe there is an unintended pause in the write_sentence function, claiming to pause between each character, where in fact it pauses after a word.

However ther is already a pause after a word, namely, at the end of the write_word function.

    def write_sentence(self, sentence):
        self.actions.pause(std_positive(1.3, 1, 0.2)) # Opening a sentence
        words = sentence.split(" ")
        if len(words) > 0:
            for i in range(len(words)-1):
                self.write_word(words[i])
                self.actions.pause(std_positive(0.21, 0.03, 0.011)) # Pauze between characters (within a word)
                self.write_character(" ")
            self.write_word(words[-1])

    def write_word(self, word):
        self.actions.pause(std_positive(0.47, 0.21, 0.05)) # Opening a word
        characters = list(word)
        if len(characters) > 0:
            for i in range(len(characters)-1):
                self.write_character(characters[i])
                self.actions.pause(std_positive(0.21, 0.03, 0.011)) # Pauze between characters (within a word)
            self.write_character(characters[-1])
        self.actions.pause(std_positive(0.2, 0.08, 0.01)) # Closing a word

@droefs Am I correct to assume that the pause in write_sentence preceding the comment # Pauze between characters (within a word) can be removed?

@basvdl97
Copy link
Contributor Author

basvdl97 commented Jan 11, 2023

I found a possible second case where this occurs:

def key_down(self, value, element=None, addDelayAfter=True):
        if element is not None:
            self.click(element)
        self.actions.key_down(value)
        if addDelayAfter:
            self.actions.pause(std_positive(0.06, 0.035, 0.013)) # Specific version of addDelayAfterAction()
        return self

def write_character(self, character):
        special_characters = "!@#$%^&*()_+{}|:<>?"
        if character.isupper() or character in special_characters:
            self.actions.key_down("\ue008")
            self.actions.pause(std_positive(0.06, 0.035, 0.005)) # Time after shift press
        self.actions.key_down(character)
        self.actions.pause(std_positive(0.06, 0.035, 0.013)) # Dwell time
        self.actions.key_up(character)
        if character.isupper() or character in special_characters:
            self.actions.pause(std_positive(0.03, 0.015, 0.003)) # Time before shift release
            self.actions.key_up("\ue008")

In this function write_character there is a pause commented as # Dwell delay. I understand the need for the dwell however the timings seem to be exactly the same as the pause after key_down when addDelayAfter=True. Since addDelayAfter=True by default I believe there might be on average twice the delay that is intended.

@droefs
Copy link
Owner

droefs commented Jan 29, 2023

Great catch! You are correct in both cases.

@droefs Am I correct to assume that the pause in write_sentence preceding the comment # Pauze between characters (within a word) can be removed?

Yes

Since addDelayAfter=True by default I believe there might be on average twice the delay that is intended.

Indeed. The argument addDelayAfter should be set to false when calling key_down(). This is probably a regression bug form when the optional addDelayAfter parameter was introduced. It also appears in the click() function and maybe also in others. I will add a addDelayAfter=False argument in all relevant functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants