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

use pytest-parallel thread rather than process #475

Open
zhupengfarmer opened this issue Apr 4, 2023 · 3 comments
Open

use pytest-parallel thread rather than process #475

zhupengfarmer opened this issue Apr 4, 2023 · 3 comments

Comments

@zhupengfarmer
Copy link

selene does not support thread concurrency for automation execution

@yashaka
Copy link
Owner

yashaka commented Apr 4, 2023

It should support anything, because you can create your own browser for any case.

Selene has shared browser object, already predefined for you, that you can import as:

from selene import browser

or (may be deprecated)

from selene.support.shared import browser

This browser uses 1 global shared per process driver instance. Hence, of course, it will not work if you paralellize per thread.

But you can create in each thread - your own browser by

from selene import Browser, Config

browser = Browser(Config(driver=..., **other_options))

Then everything should be fine...

Should we improve the behavior of shared browser object? Hm... Probably yes, if this is not a big deal. Let's investigate this topic... If somebody can help with this, prepare examples, share some snippets, would be great...

@zhupengfarmer
Copy link
Author

I also used selenide before because some testing scenarios require threads to share some data, such as testing scenarios where I need two browsers to interact. Therefore, relying on thread concurrency is not very suitable for process concurrency

The thread concurrency provided by the Java testng framework

However, selenide also has issues with thread concurrency, as it does not want to be thread safe during thread concurrency

Add posibility to set different capabilities for each browser session in Configuration class

@yashaka
Copy link
Owner

yashaka commented Apr 4, 2023

Add posibility to set different capabilities for each browser session in Configuration class

This will come pretty soon, in Selene 2.0.0rc1. Currently in "work in progress". Tills this will be done, you can create your own driver based on capabilities and pass it eather browser.config.driver = HERE or browser = Browser(Config(driver=HERE))

where I need two browsers to interact

For this case, currently, in Selene you just create the needed amount of browsers by browser2 = Browser(Config(driver=driver2)); browser3 = Browser(Config(driver=driver3)); # and so on...

Regarding thread concurrency in Python... I'll think what we can do for this in Selene in context of adapting shared selene browser object (the one from: from selene import browser)... We never looked into this, because in Python thread-like parallisation is not efficient like in Java, and everybody used process-like parallisation... Let's see... maybe something changed, or maybe there are some use cases in context of test automation where thread-like concurrency make sense... If you share some actualy use cases with code snippets, it would help! Thank you!

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