Awesome dude! To the point and selfless (there were no ads interrupting the flow). Not so many guys can do half as much as you did in a span of 12 min. Thank you.
You all probably dont care at all but does someone know a tool to log back into an instagram account? I was stupid forgot my password. I love any help you can offer me
@Camden Louie I really appreciate your reply. I got to the site through google and im trying it out now. I see it takes a while so I will reply here later when my account password hopefully is recovered.
Wow.. Its pretty useful, May be you can also explain the parameter in the method like (threadPoolSize, Invocation count and timeout). The purpose for these parameters. Try to make more descriptive . Other wise the stuffs are pretty cool. thanks bro
What if we don't give ThreadCount, Only parallel = methods would be there . Will the methods run parallel OR methods will run sequentially using one thread OR its a compilation error ?
Hi Raghav, I have a question. How to do parallel execution if launch browser mentioned in "@BeforeClass" annotation method? Please provide your input. Thanks in advance..
Hi..I'm facing issue in parallel execution.. sequential mode test cases are running fine.. In parallel, few test cases are getting failed due to unable to click or focus element in the browser..Any suggestion to resolve this issue?
Hi Reena There are a few things that you can do to resolve the issue of test cases failing due to unable to click or focus element in the browser when running in parallel with TestNG and Selenium Java: * Use a different browser. If you are using a single browser for all of your test cases, try using a different browser for the parallel test cases. This can help to avoid conflicts between the test cases. * Increase the timeout value. The timeout value is the amount of time that Selenium will wait for an element to be found or interacted with before it times out. If the timeout value is too low, the test cases may fail because they are not able to find or interact with the elements in time. * Use a different locator strategy. The locator strategy is the way that Selenium finds an element on the page. If the locator strategy that you are using is not working well in parallel, try using a different locator strategy. * Use a different thread pool. The thread pool is the number of threads that TestNG will use to run the test cases. If the thread pool is too small, the test cases may not be able to access the elements on the page in time. Here are some additional things to keep in mind: * The browser that you use for parallel test cases should be the same browser that you use for sequential test cases. * The timeout value should be long enough to allow the test cases to find and interact with the elements on the page. * The locator strategy that you use should be reliable and efficient. * The thread pool should be large enough to allow all of the test cases to run at the same time. I hope this helps
Hi, for running different method in parallel way then the methods should be runnable in parallel way first. And second if we are running parallel methods test then we should test those methods in different browser to get the result quickly for parallel test cases. correct me if I am wrong
Sir I was facing the issue with running both methods parallely as only one of them was executing. Then I changed the driver instance to driver1 and driver2 in both methods respectively and it started running fine.
When I am using page object model, I am facing issues in calling the objects from the pages. May be it's due to page factory initialization. Can you help providing any solution??
@@RaghavPal heyy thanks for the reply. I got it resolved. Actually I used thread safe to get the driver instance and I got some error as I initialized the page objects inside the page class using page factory.init(driver, this). The problem solved when I initialized the page objects in @test (page factory.init(driver, LOGINpage)
Ayushman Yes, to execute multiple test classes in parallel using TestNG, you need to set the `parallel` attribute to `classes` in the `` tag of your testng.xml file. This will instruct TestNG to run each test class in a separate thread, potentially improving the overall test execution time. For example, consider the following testng.xml file: ```xml
``` In this example, the `parallel` attribute is set to `classes`, indicating that TestNG should execute the `Test1`, `Test2`, and `Test3` classes in parallel. When you run this testng.xml file, each test class will be executed in a separate thread, potentially reducing the overall test execution time. Remember that parallel test execution can introduce some overhead and instability, especially if the test classes share state or resources. Use parallel execution selectively for tests that are independent and do not share state.
Hello sir i am doing parallel execution in my current project using testng but sir i have one doubt in my case lets consider chrome browser 1 and Chrome browser 2 running parallel and now if chrome browser 1 first testcase run at same time chrome browser 2 first testcase should run n so one like parallel same test should run without any time dealy even if any test fails at any browser so could you please help me and guide me how to implement this
Hi Rushieksh To implement parallel execution in TestNG so that the same test runs on different browsers at the same time, you can use the following steps: 1. Create a testng.xml file and specify the parallel attribute. The value of the parallel attribute can be "methods", "tests", "classes", or "instances". In your case, you want to run the same test on different browsers, so you would set the parallel attribute to "methods". 2. Create a test class for each browser. In your case, you would need to create two test classes, one for Chrome browser 1 and one for Chrome browser 2. 3. In each test class, create a method for the test that you want to run. 4. In the testng.xml file, add the test class for each browser to the suite element. 5. Run the testng.xml file. The tests will be run in parallel, and the same test will run on each browser at the same time. If a test fails on one browser, the test will not continue on the other browser. Here is an example of a testng.xml file that you can use: ``` methods
``` In this example, the parallel attribute is set to "methods", so the same test will run on Chrome browser 1 and Chrome browser 2 at the same time. I hope this helps
Hi I am working on Parallel Execution in testng.My test case is I wanted to create a extent report Once I ran all the test cases parallel. am getting an extent report with mix and match steps from all the test cases.Not sure how to fix this
Hi Rahul To perform parallel testing in Appium, you can make use of the Appium server's new grid feature. The grid feature enables you to distribute your tests across multiple devices or emulators for faster execution. Here are the steps to perform parallel testing in Appium 2.0: Launch the Appium server with the --relaxed-security flag: appium --relaxed-security Open the Appium Desktop client and create multiple sessions by selecting the New Session option from the File menu. Configure each session with a unique device or emulator. Start running your tests using the Appium client or your preferred test framework. When running your tests, specify the --session-override flag and the session ID of the Appium session you want to use for each test. For example, if you are using Appium with Java and TestNG, you can create a TestNG XML file that specifies the tests you want to run and the Appium session ID for each test. Here is an example of a TestNG XML file that runs tests on two different devices:
In this example, the deviceName parameter specifies a unique name for each device, the udid parameter specifies the device UDID, and the appiumServerUrl parameter specifies the URL of the Appium server for each device. When running your tests using TestNG, you can specify the TestNG XML file and the --parallel flag to run your tests in parallel: mvn clean test -DsuiteXmlFile=testng.xml -Dparallel=tests That's it! Your tests will now run in parallel across multiple devices or emulators using the Appium server's new grid feature. Alternatively, if you can take subscription of cloud platforms like Browserstack, Saucelabs etc. you can use their devices too
Will you send me the link of testng playlist because this one is not in selenium playlist thats your first playlist .i want all testng video from you because you are very easily explain it ..and its easy to understand .
Thank you very much! I have a question. At 8:53 why is only one browser closed? Aren't the two browsers supposed to be closed? I'm encountering the same problem. Could you show me how to close them all?
Sir. I am commeting bit late. When i am trying to run parallel tests using testng two browsers are getting opened but all the inputs are going to one browser only. How go get this issue resolved.
Hi Yerramilli The issue that you are facing is due to the fact that by default, TestNG uses a single thread to execute all your tests. This means that even if you are running multiple tests in parallel, they will all be executed in the same thread. To resolve this issue, you need to use the parallel attribute in the @Test annotation. The parallel attribute specifies the number of threads that TestNG should use to execute the test. For example, the following code will run the @Test annotated method in two parallel threads: Java @Test(parallel = 2) public void testMethod() { // Your test code goes here. } Once you have added the parallel attribute to your @Test annotation, TestNG will start two threads and execute the testMethod() method in each thread. This will ensure that your tests are executed in parallel and that the inputs are not going to the same browser. Here are some additional things to keep in mind: * The parallel attribute can take a value of 1 or more. * If you set the parallel attribute to a value greater than 1, TestNG will create a new thread for each test that you run. * If you are running your tests on a machine with limited resources, you may want to set the parallel attribute to a lower value I hope this help
@@RaghavPal hi sir thanks a lot for your reply. Infact I am implementing testng framework in my organization by learning from your videos. The issue i faced is with the Webdriver I am using bcoz it is static and when we use static webdriver parallel runs will fail as everything will be messed up. To avoid this issue i used threadlocal. So now my script is running in parallel. Please make a video on thread local sir there are so many people who are facing this issue, if u make a video on using threadlocal it will help for many people like me.
Sure, I will plan When you use a static webdriver, all threads share the same instance of the webdriver. This can cause problems if two threads are trying to interact with the same element on the page at the same time. For example, if one thread is trying to click on an element and the other thread is trying to type into the same element, the results will be unpredictable. Using ThreadLocal, each thread gets its own instance of the webdriver. This ensures that the threads do not interfere with each other.
Hello Raghav, Thanks for creating this video. I need one solution to a problem. Actually, I have around 200 test cases to execute. All those(200 TC) I want to execute on Chrome and Firefox parallelly. Also, we have different user types, like admin, super admin, manager. Now I want to run my test cases parallelly on chrome and firefox but with different user types. This means, chrome should use Admin user credentials and firefox should use super admin user credentials. I don't want you to create a full video on this. If possible just suggest the approach to follow.
Hi Pradosh, you should be able to get diff credentials from a data file. You can use data provider from testng. Check this - stackoverflow.com/questions/31521466/testng-parallel-execution-with-dataprovider
Thank you for always sharing your knowledge with us, it truly helps alot. I’m trying to find if is there a way to run multiple threads based on number of data in the excel file using 1 scenario on the feature file? I’m using testng for my parallel execution.
Hi raghav, First of all, your videos are nice. Currently I work on parallel execution with testNG. I have beforemethod class and aftermethod class when I open and close drivers for each method. But, I want to create n number of drivers based on thread count only once and reuse the same drivers for all methods/threads. Could you please explain how to do it in testNG
Hello Sir, Thank you all your trainings. They indeed help a lot. In my project I need to implement parallel execution in a Selenium with Java + cucumber framework. I have command steps in my feature files. I need to do this without maven. Can you please guide me for same. Thank you.
Hi Raghav, How we can get all CSS values of headings on webpages (ex: h1, h2, h3 etc) and how can I print those in console. For this, Is possible by java ? If not possible by java which programming language Will helps to get all CSS values of headings, paragraphs etc.. on any webpages. Am able to get css value by finding the element in selenium ex: Driver. findelement(By.id("sample"). getcssvalue("colour"). but it won't work for all website because we have to find element. So, please give me any suggestions on this. Is possible to get all CSS values through any programming language?
Hi Gowri, you can get css value by using getCssValue() method example element.getCssValue("font-weight"); You can see some more information here and see how to use in your case - stackoverflow.com/questions/17255611/selenium-webdriver-getcssvalue-method
Hi, i have classA which has 4@test method in it. I have an XML file which has 4 test tags in it say iphone ipad mobile and tablet and all the 4 tests were trying to execute the same classA. Could you pls explain how to achieve parallelism in this case along with thread safety
@@RaghavPal hi, i have a doubt over here. Mentioning parallel=methods does this mean the 3 tests will be run by 3 different threads or the same thread will run all the 3 methods.
Please do a video on how to fix issues when running parallel tests. For instance, I have a counter for reporting test steps, but in the end, the steps are out of order and even repeated. Each test case restarts at step 1, but the steps might look like this in the report: Test B: steps 1,2,3,3,3,7 Test B: steps 2,2,2,6,7 Plus steps fail. Plus I see tests that do the same steps in 2 test cases end up doing the same step into 1 browser. So if test A enters "ABC" into edit field "Address" and test B enters "123", Selenium enters "ABC123" into the field.
@@RaghavPal thank you very much. I found this is acheived using the testNGCucumberRunner. How can i add and run a maven goal for the test I want to test from intellij?
Hi Vivek, By default the classes in the java.io package always resolve relative pathnames against the current user directory. This directory is named by the system property user.dir, and is typically the directory in which the Java virtual machine was invoked. Pls check this - softwareengineering.stackexchange.com/questions/302988/trying-to-understand-on-what-user-dir-property-actually-means
Hi Prashant, Yes you can, you can put classes in the parallel node. Here is one example www.seleniumeasy.com/testng-tutorials/parallel-execution-of-classes-in-testng
@@RaghavPal On 9th minuet, my question related driver instance, driver is non-static both test method refer to single driver instance, here the question arise when run your test cases in parallel then each test should be treated as different - different thread right but its point to same. could you evaluate this. Thanks Harsh
To run the same test class for multiple times (50 times) using TestNG, you can use the `@Test(invocationCount = 50)` annotation. This annotation will tell TestNG to run the test class 50 times. For example, the following code will run the test class `MyTestClass` 50 times: ```java import org.testng.annotations.Test; public class MyTestClass { @Test(invocationCount = 50) public void testSomething() { // Do something } } ``` This will run the `testSomething()` method 50 times. The output of the test will be the same as if you ran the test class once, but the test will be run 50 times in parallel. You can also use the `threadPoolSize` attribute to specify the number of threads that TestNG should use to run the test class. For example, the following code will run the test class `MyTestClass` 50 times using 10 threads: ```java import org.testng.annotations.Test; public class MyTestClass { @Test(invocationCount = 50, threadPoolSize = 10) public void testSomething() { // Do something } } ``` This will run the `testSomething()` method 50 times, but it will use 10 threads to do so. This can be helpful if you are running a test class that is CPU-intensive or if you want to test the performance of your application. I hope this helps
You missed the Failure while executing. I am getting error while executing 3 Tests parallel, you also couldn't execute. When we deal with driver object, we need to maintain session and object count also. All three Tests should have distinct WebDriver object.
Awesome dude! To the point and selfless (there were no ads interrupting the flow). Not so many guys can do half as much as you did in a span of 12 min. Thank you.
You're welcome Tom.
You all probably dont care at all but does someone know a tool to log back into an instagram account?
I was stupid forgot my password. I love any help you can offer me
@Keegan Garrett instablaster ;)
@Camden Louie I really appreciate your reply. I got to the site through google and im trying it out now.
I see it takes a while so I will reply here later when my account password hopefully is recovered.
@Camden Louie it did the trick and I finally got access to my account again. I'm so happy!
Thanks so much, you saved my account!
A smooth 12 min of valid information
Happy to know Gurpal
The explanation was very clear with no interruption. You also explained other small things which usually people don't do. Thanks much.
You are welcome Laxmi
What a content man....hila diya sirji aapne
Thanks Rahul
Sahi ja rahe ho sir. Sidha mst explain kiya.! Great
Thanks for watching Jayprakash
Hi Sir, Most of your videos are very easy to understand and follow. Great effort, Thanks!
You are most welcome Soumya
Hello Sir
Thank you for creating this video we can easily understand parallel testing
Glad to hear that Yashwanti
Thank you sir.... 👍
Most welcome
Thank you. Your videos are easy to follow and understand.
You're welcome Murat
Clear and simple. Thanks!
You're welcome!
You r great bro!
Thanks
uh explained it in very simple way bro..thanks a lot
You're welcome Purushottam
Thanks a lot!!
You're welcome!
great vedio in parallel testing...Very thankful for sharing this.....
You're welcome Shilpa
Great explanation sir !!!!!!
Is this enough to explain in the interview *
This should be enough for any project using TestNG, you can watch all the TestNG related video of this series and should be enough for interview
Clarity is there in vedio
And Nice Explanation
Thanks Sindhu
crystal clear!
Thanks Eswar
Thank you sir for the amazing tutorial!
Glad it was helpful!
Hi Raghav, if i just declare thread count as 2 or more but do not specify parallel run.
Would class/test still run in parallel?
No Samiksha, have you tried that
Wow.. Its pretty useful, May be you can also explain the parameter in the method like (threadPoolSize, Invocation count and timeout). The purpose for these parameters. Try to make more descriptive . Other wise the stuffs are pretty cool. thanks bro
Sure Karandeep, will take that up soon
Awesome way of explanation... Great ...thanks alot brother...👍
You're welcome
What if we don't give ThreadCount, Only parallel = methods would be there . Will the methods run parallel OR methods will run sequentially using one thread OR its a compilation error ?
Hi Digambar, just try it out. I will check too
@@RaghavPal Methods will run in
parallel, even though if u didn't mention Threadcount
Hi Raghav, I have a question. How to do parallel execution if launch browser mentioned in "@BeforeClass" annotation method? Please provide your input. Thanks in advance..
Hi Sushma, I will check on this and will try to do a session. Meanwhile, pls check online examples
I will learn , lot from u sir , I m selenium beginner , help me sir.
Sure, You can go through the videos and let me know if you face any issues
Ok Sir...Thank You...😊
Thanks you for this tutorial. could you provide the video link to add testNG plugin?
Sure Anna ruclips.net/video/yyUyi8s42dE/видео.html
@@RaghavPal thanks
Hi..I'm facing issue in parallel execution.. sequential mode test cases are running fine.. In parallel, few test cases are getting failed due to unable to click or focus element in the browser..Any suggestion to resolve this issue?
Hi Reena
There are a few things that you can do to resolve the issue of test cases failing due to unable to click or focus element in the browser when running in parallel with TestNG and Selenium Java:
* Use a different browser. If you are using a single browser for all of your test cases, try using a different browser for the parallel test cases. This can help to avoid conflicts between the test cases.
* Increase the timeout value. The timeout value is the amount of time that Selenium will wait for an element to be found or interacted with before it times out. If the timeout value is too low, the test cases may fail because they are not able to find or interact with the elements in time.
* Use a different locator strategy. The locator strategy is the way that Selenium finds an element on the page. If the locator strategy that you are using is not working well in parallel, try using a different locator strategy.
* Use a different thread pool. The thread pool is the number of threads that TestNG will use to run the test cases. If the thread pool is too small, the test cases may not be able to access the elements on the page in time.
Here are some additional things to keep in mind:
* The browser that you use for parallel test cases should be the same browser that you use for sequential test cases.
* The timeout value should be long enough to allow the test cases to find and interact with the elements on the page.
* The locator strategy that you use should be reliable and efficient.
* The thread pool should be large enough to allow all of the test cases to run at the same time.
I hope this helps
Hi, for running different method in parallel way then the methods should be runnable in parallel way first. And second if we are running parallel methods test then we should test those methods in different browser to get the result quickly for parallel test cases. correct me if I am wrong
ok
Sir I was facing the issue with running both methods parallely as only one of them was executing. Then I changed the driver instance to driver1 and driver2 in both methods respectively and it started running fine.
Thanks for sharing Rishabh
Fantastic!
Glad you like it Sayed
When I am using page object model, I am facing issues in calling the objects from the pages. May be it's due to page factory initialization. Can you help providing any solution??
Hi Raviteja, what is the error. Do you have logs. PLs check with the video again in case you missed any step
@@RaghavPal heyy thanks for the reply. I got it resolved. Actually I used thread safe to get the driver instance and I got some error as I initialized the page objects inside the page class using page factory.init(driver, this). The problem solved when I initialized the page objects in @test (page factory.init(driver, LOGINpage)
Hi Raghav
Is there any video which will help us to execute multiple suite XML files parallely
Hi Adiki, you can check this howtodoinjava.com/testng/testng-executing-parallel-tests/
can take more online help
If I want to execute test() in different class have to select parallel as classes instead method?
Ayushman
Yes, to execute multiple test classes in parallel using TestNG, you need to set the `parallel` attribute to `classes` in the `` tag of your testng.xml file. This will instruct TestNG to run each test class in a separate thread, potentially improving the overall test execution time.
For example, consider the following testng.xml file:
```xml
```
In this example, the `parallel` attribute is set to `classes`, indicating that TestNG should execute the `Test1`, `Test2`, and `Test3` classes in parallel. When you run this testng.xml file, each test class will be executed in a separate thread, potentially reducing the overall test execution time.
Remember that parallel test execution can introduce some overhead and instability, especially if the test classes share state or resources. Use parallel execution selectively for tests that are independent and do not share state.
Thanks Sir, very helpful... :-)
Most welcome Namit
Hello sir i am doing parallel execution in my current project using testng but sir i have one doubt in my case lets consider chrome browser 1 and Chrome browser 2 running parallel and now if chrome browser 1 first testcase run at same time chrome browser 2 first testcase should run n so one like parallel same test should run without any time dealy even if any test fails at any browser so could you please help me and guide me how to implement this
Hi Rushieksh
To implement parallel execution in TestNG so that the same test runs on different browsers at the same time, you can use the following steps:
1. Create a testng.xml file and specify the parallel attribute. The value of the parallel attribute can be "methods", "tests", "classes", or "instances". In your case, you want to run the same test on different browsers, so you would set the parallel attribute to "methods".
2. Create a test class for each browser. In your case, you would need to create two test classes, one for Chrome browser 1 and one for Chrome browser 2.
3. In each test class, create a method for the test that you want to run.
4. In the testng.xml file, add the test class for each browser to the suite element.
5. Run the testng.xml file.
The tests will be run in parallel, and the same test will run on each browser at the same time. If a test fails on one browser, the test will not continue on the other browser.
Here is an example of a testng.xml file that you can use:
```
methods
```
In this example, the parallel attribute is set to "methods", so the same test will run on Chrome browser 1 and Chrome browser 2 at the same time.
I hope this helps
Hi
I am working on Parallel Execution in testng.My test case is I wanted to create a extent report Once I ran all the test cases parallel. am getting an extent report with mix and match steps from all the test cases.Not sure how to fix this
Hi Sirisha, you can take some help from here - stackoverflow.com/questions/52811017/extent-report-issue-parallel-testing
@raghav can you guide me how parallel testing is done in appium?? I am using appium 2.0.
Hi Rahul
To perform parallel testing in Appium, you can make use of the Appium server's new grid feature. The grid feature enables you to distribute your tests across multiple devices or emulators for faster execution.
Here are the steps to perform parallel testing in Appium 2.0:
Launch the Appium server with the --relaxed-security flag:
appium --relaxed-security
Open the Appium Desktop client and create multiple sessions by selecting the New Session option from the File menu. Configure each session with a unique device or emulator.
Start running your tests using the Appium client or your preferred test framework. When running your tests, specify the --session-override flag and the session ID of the Appium session you want to use for each test.
For example, if you are using Appium with Java and TestNG, you can create a TestNG XML file that specifies the tests you want to run and the Appium session ID for each test.
Here is an example of a TestNG XML file that runs tests on two different devices:
In this example, the deviceName parameter specifies a unique name for each device, the udid parameter specifies the device UDID, and the appiumServerUrl parameter specifies the URL of the Appium server for each device.
When running your tests using TestNG, you can specify the TestNG XML file and the --parallel flag to run your tests in parallel:
mvn clean test -DsuiteXmlFile=testng.xml -Dparallel=tests
That's it! Your tests will now run in parallel across multiple devices or emulators using the Appium server's new grid feature.
Alternatively, if you can take subscription of cloud platforms like Browserstack, Saucelabs etc. you can use their devices too
Will you send me the link of testng playlist because this one is not in selenium playlist thats your first playlist .i want all testng video from you because you are very easily explain it ..and its easy to understand .
Hi Komal, all the testng videos are in the selenium playlist - automationstepbystep.com/
@@RaghavPal thankyou sir .☺️
wow so useful Thanks !
Glad to know this
i love your channel, keep going !
Thanks a lot Andi
Hi , is this called asynchronous testing.Could you please clarify it.
Hi Nishal, not sure on approach testing
Thank you very much! I have a question.
At 8:53 why is only one browser closed? Aren't the two browsers supposed to be closed?
I'm encountering the same problem. Could you show me how to close them all?
Hi Minh, I will check
Thank you.
Hi Raghav.. loved ur videos.. can u tell me if its possible to do testing on multiple browsers with multiple threads.. or we need to use grid for that
You can do, Se Grid is one option, then you can use some cloud services like Saucelabs and Browserstack. Can also use container engines like Docker
Sir. I am commeting bit late. When i am trying to run parallel tests using testng two browsers are getting opened but all the inputs are going to one browser only. How go get this issue resolved.
Hi Yerramilli
The issue that you are facing is due to the fact that by default, TestNG uses a single thread to execute all your tests. This means that even if you are running multiple tests in parallel, they will all be executed in the same thread.
To resolve this issue, you need to use the parallel attribute in the @Test annotation. The parallel attribute specifies the number of threads that TestNG should use to execute the test.
For example, the following code will run the @Test annotated method in two parallel threads:
Java
@Test(parallel = 2)
public void testMethod() {
// Your test code goes here.
}
Once you have added the parallel attribute to your @Test annotation, TestNG will start two threads and execute the testMethod() method in each thread. This will ensure that your tests are executed in parallel and that the inputs are not going to the same browser.
Here are some additional things to keep in mind:
* The parallel attribute can take a value of 1 or more.
* If you set the parallel attribute to a value greater than 1, TestNG will create a new thread for each test that you run.
* If you are running your tests on a machine with limited resources, you may want to set the parallel attribute to a lower value
I hope this help
@@RaghavPal hi sir thanks a lot for your reply. Infact I am implementing testng framework in my organization by learning from your videos. The issue i faced is with the Webdriver I am using bcoz it is static and when we use static webdriver parallel runs will fail as everything will be messed up. To avoid this issue i used threadlocal. So now my script is running in parallel. Please make a video on thread local sir there are so many people who are facing this issue, if u make a video on using threadlocal it will help for many people like me.
Sure, I will plan
When you use a static webdriver, all threads share the same instance of the webdriver. This can cause problems if two threads are trying to interact with the same element on the page at the same time. For example, if one thread is trying to click on an element and the other thread is trying to type into the same element, the results will be unpredictable.
Using ThreadLocal, each thread gets its own instance of the webdriver. This ensures that the threads do not interfere with each other.
Hello Raghav,
Thanks for creating this video. I need one solution to a problem.
Actually, I have around 200 test cases to execute. All those(200 TC) I want to execute on Chrome and Firefox parallelly.
Also, we have different user types, like admin, super admin, manager.
Now I want to run my test cases parallelly on chrome and firefox but with different user types. This means, chrome should use Admin user credentials and firefox should use super admin user credentials.
I don't want you to create a full video on this. If possible just suggest the approach to follow.
Okay, you can do it through config and data files. I will plan a session
If yes , please how do we prevent that . Incase we also want each instances having different useragent
Here we are using a website like a user. We can provide diff user credentials by doing parameterization
Hi Sir, Could you please help me on How to do parallel execution using multiple user credential ?
Hi Pradosh, you should be able to get diff credentials from a data file. You can use data provider from testng. Check this - stackoverflow.com/questions/31521466/testng-parallel-execution-with-dataprovider
Thank you for always sharing your knowledge with us, it truly helps alot. I’m trying to find if is there a way to run multiple threads based on number of data in the excel file using 1 scenario on the feature file?
I’m using testng for my parallel execution.
Hi Pamza, can be done, will need to add scripts for it
@@RaghavPal Awesome, thank you so much, I’ll keep an eye 🙌🏽🙌🏽
Hi raghav,
First of all, your videos are nice. Currently I work on parallel execution with testNG. I have beforemethod class and aftermethod class when I open and close drivers for each method. But, I want to create n number of drivers based on thread count only once and reuse the same drivers for all methods/threads. Could you please explain how to do it in testNG
Hi, you can do this in a parent class and inherit in child classes, Can check some online examples
Thanks for sharing but can you please share the same for Junit framework as well?
I will plan Prafull
When u do it in parallel, does it allow the website / browser to store cookies
Hi Michael, storing cookies is the functionality at the website end.
Hello Sir, Thank you all your trainings. They indeed help a lot. In my project I need to implement parallel execution in a Selenium with Java + cucumber framework. I have command steps in my feature files. I need to do this without maven. Can you please guide me for same.
Thank you.
Hi Dhanashree, you can watch the cucumber selenium tutorials here - automationstepbystep.com/
Hi Raghav,
How we can get all CSS values of headings on webpages (ex: h1, h2, h3 etc) and how can I print those in console.
For this, Is possible by java ?
If not possible by java which programming language Will helps to get all CSS values of headings, paragraphs etc.. on any webpages.
Am able to get css value by finding the element in selenium ex: Driver. findelement(By.id("sample"). getcssvalue("colour"). but it won't work for all website because we have to find element.
So, please give me any suggestions on this. Is possible to get all CSS values through any programming language?
Hi Gowri, you can get css value by using getCssValue() method
example element.getCssValue("font-weight");
You can see some more information here and see how to use in your case - stackoverflow.com/questions/17255611/selenium-webdriver-getcssvalue-method
Please do you have any video for python about this parallel testing in selenium
Not yet Michael
Hi, i have classA which has 4@test method in it. I have an XML file which has 4 test tags in it say iphone ipad mobile and tablet and all the 4 tests were trying to execute the same classA. Could you pls explain how to achieve parallelism in this case along with thread safety
Hi Raj, you can use testng.xml file as below
Here we have a class called ClassName and all the methods inside the class with @Test annotation will be run in parallel (4 threads in parallel)
@@RaghavPal hi, i have a doubt over here. Mentioning parallel=methods does this mean the 3 tests will be run by 3 different threads or the same thread will run all the 3 methods.
The thread count is 4, so max 4 diff threads can run in parallel
Please do a video on how to fix issues when running parallel tests. For instance, I have a counter for reporting test steps, but in the end, the steps are out of order and even repeated. Each test case restarts at step 1, but the steps might look like this in the report: Test B: steps 1,2,3,3,3,7 Test B: steps 2,2,2,6,7 Plus steps fail. Plus I see tests that do the same steps in 2 test cases end up doing the same step into 1 browser. So if test A enters "ABC" into edit field "Address" and test B enters "123", Selenium enters "ABC123" into the field.
I will do
@@RaghavPal Thanks!
Hai Sir , How can i run a cucumber feature file from testNG test method?. Please give me some idea or reference. Please help. thanks
Hi, I will check if I have a video on that, Can also check my playlists here - automationstepbystep.com/
@@RaghavPal thank you very much. I found this is acheived using the testNGCucumberRunner. How can i add and run a maven goal for the test I want to test from intellij?
I will need to check on this, for now try some online examples
@@RaghavPal I have tried that and made that working using the testNGcucumberRunner. Thanks
What is user. dir that you used
Hi Vivek, By default the classes in the java.io package always resolve relative pathnames against the current user directory. This directory is named by the system property user.dir, and is typically the directory in which the Java virtual machine was invoked.
Pls check this - softwareengineering.stackexchange.com/questions/302988/trying-to-understand-on-what-user-dir-property-actually-means
Hi Raghav, nice video, I have one question: Can we run multiple classes in parallel
Hi Prashant, Yes you can, you can put classes in the parallel node.
Here is one example www.seleniumeasy.com/testng-tutorials/parallel-execution-of-classes-in-testng
@@RaghavPal Cool, thanks a lot. That's exactly what I was looking for.
Hi Raghav,
One quick Question, Why second @Test browser not closed and failed, could you please explain
Hi Harsh, pls point the time in the video. Will help me refer and save time
@@RaghavPal On 9th minuet, my question related driver instance, driver is non-static both test method refer to single driver instance, here the question arise when run your test cases in parallel then each test should be treated as different - different thread right but its point to same. could you evaluate this.
Thanks Harsh
Usually this is taken care in the webdriver interface. I will still check more on this
@@RaghavPal Yes, i would agree with you, i will wait for your answer
Hi Raghav, did you get answer for this?
How to run the same test class for multiple times(50 time)
To run the same test class for multiple times (50 times) using TestNG, you can use the `@Test(invocationCount = 50)` annotation. This annotation will tell TestNG to run the test class 50 times.
For example, the following code will run the test class `MyTestClass` 50 times:
```java
import org.testng.annotations.Test;
public class MyTestClass {
@Test(invocationCount = 50)
public void testSomething() {
// Do something
}
}
```
This will run the `testSomething()` method 50 times. The output of the test will be the same as if you ran the test class once, but the test will be run 50 times in parallel.
You can also use the `threadPoolSize` attribute to specify the number of threads that TestNG should use to run the test class. For example, the following code will run the test class `MyTestClass` 50 times using 10 threads:
```java
import org.testng.annotations.Test;
public class MyTestClass {
@Test(invocationCount = 50, threadPoolSize = 10)
public void testSomething() {
// Do something
}
}
```
This will run the `testSomething()` method 50 times, but it will use 10 threads to do so. This can be helpful if you are running a test class that is CPU-intensive or if you want to test the performance of your application.
I hope this helps
You missed the Failure while executing. I am getting error while executing 3 Tests parallel, you also couldn't execute. When we deal with driver object, we need to maintain session and object count also. All three Tests should have distinct WebDriver object.
Thanks for informing Hamid, I will check this