WasiqB / coteafs-selenium

:computer: Selenium WebDriver wrapper framework in Java for clean and maintainable tests.
https://wasiqb.github.io/projects/selenium/
Apache License 2.0
77 stars 35 forks source link

CrossBrowser testing/Prallel testing #119

Closed MonoAutomation closed 4 years ago

MonoAutomation commented 4 years ago

Its good to see the framework but I am not understanding how it can be useful for parallel testing(on different browsers) can you add some tests on this and put some details how e we can use this framework for parallel testing

WasiqB commented 4 years ago

@MonoAutomation , check out testng-all-browsers.xml file and enable parallel parameter in it and select parallel mode to test. You can also enable the tests which are marked as enabled="false".

After updating the file, you can run it like any other testng file and the tests will run simultaneously on all the mentioned browser. This is useful to get quick feedback of the tests while running on different browsers at the same time.

Let me know if you still find it difficult to run in parallel.

MonoAutomation commented 4 years ago

I enabled in testng-all-browsers.xml but no luck, should I rename it to testng.xml after updates? what purpose we are using "selenium-config.yaml" do I need to change anything here? will this framework supports on Mac OS? bcz I have not seen any browser invoking

WasiqB commented 4 years ago

@MonoAutomation , I'll create a small documentation about this and update you when it's ready.

In meantime, can you share how are you running the TestNG xml file I mentioned in my previous comment?

MonoAutomation commented 4 years ago

BROWSER, appSetting ().getBrowser ().name ())....I don't see any method getBrowser() implementation in appSetting() ..do we need to add this method getBrowser()?

-----parallel xml---- <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

I renamed it as testing.xml

WasiqB commented 4 years ago

@MonoAutomation , you don't have to do this. Wait till I update the README with more details on how to run the tests..

Try going thru the src/test directory to understand how to write the test OR check the README where I already did some detailing on how to write the test.

WasiqB commented 4 years ago

@MonoAutomation , Readme is updated with more details about running the tests, kindly check and let me know if that helped you.

MonoAutomation commented 4 years ago

Thank you for updating the doc, but still not getting..if I want to run my tests on different browsers parallelly if I pass CHROME,SAFARI,FIREFOX on config file ...It will throw error because it is accepting only one browser name . can you explain how and where I can mention browsers to run my suite?

WasiqB commented 4 years ago

@MonoAutomation , to make this more clear, the framework is designed that way only, in config it will accept only one browser at a time. What you can do is, create different test blocks for each browsers in your testng.xml file and pass the browser name in the test parameter directly, this will override the browser mentioned in the config.

Kindly check the sample testng.xml file where I am running 1st test on local chrome, 2nd test on Selenium Grid Chrome and 3rd test on BrowserStack Chrome.

Similarly there is one more file testng-all-browsers.xml, where I am running test on 4 different browsers.

MonoAutomation commented 4 years ago

I have updated as <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">

moreover , let me know where all drivers getting stored in the project...its seems having some chrome version problem...so getting Starting ChromeDriver 2.46.628411 (3324f4c8be9ff2f70a05a30ebc72ffb013e1a71e) on port 7911 Only local connections are allowed.

WasiqB commented 4 years ago

@MonoAutomation , drivers are handled dynamically using WebDriverManager, The framework will download required driver automatically. Normally the driver is stored in <User>/.m2/repository/webdriver folder.

Only local connections are allowed.

You can ignore this as it is only warning given by the driver.

MonoAutomation commented 4 years ago

Chrome browser not at all launching and after completion of one set of test cases ,execution is stopped and no further execution to run on other browsers like Firefox.....

WasiqB commented 4 years ago

@MonoAutomation , try running the following testng.xml against my repository,

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
    <listeners>
        <listener class-name="com.github.wasiqb.coteafs.listeners.ConfigListener"/>
        <listener class-name="com.github.wasiqb.coteafs.listeners.SuiteListener"/>
        <listener class-name="com.github.wasiqb.coteafs.listeners.TestListener"/>
        <listener class-name="com.github.wasiqb.coteafs.listeners.ExecutionListener"/>
        <listener class-name="com.github.wasiqb.coteafs.listeners.DataProviderListener"/>
        <listener class-name="com.github.wasiqb.coteafs.listeners.AnnotationTransformer"/>
    </listeners>
    <test name="Test Local">
        <classes>
            <class name="com.github.wasiqb.coteafs.selenium.SeleniumTest">
                <methods>
                    <include name="testSignIn"/>
                    <include name="testNewCustomer"/>
                    <include name="testEditCustomer"/>
                    <include name="testNewAccount"/>
                    <include name="testDeleteAccount"/>
                    <include name="testDeleteCustomer"/>
                </methods>
            </class>
        </classes>
    </test>
</suite>

using the following command in terminal / command line,

mvn clean install

Use the latest Chrome browser.

MonoAutomation commented 4 years ago

No luck, moreover am using Mac and IntelliJ....after updates..getting the below error (Driver info: chromedriver=2.46.628411 (3324f4c8be9ff2f70a05a30ebc72ffb013e1a71e),platform=Mac OS X 10.14.6 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 0 milliseconds For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'

still chrome not being launched

WasiqB commented 4 years ago

@MonoAutomation , this framework works on any OS (Mac, Windows and Linux) and on any browser (Chrome, Firefox, Edge, IE and Safari). I am not sure how you are trying execute the tests.

I would suggest you to share the following,

  1. Steps you take to execute the tests
  2. Screenshot of the Error
  3. Your project code hosted on GitHub.

If you are still in doubt if this framework really works, you can check out the build pipeline where the tests are being executed on Linux Docker container.

MonoAutomation commented 4 years ago

I am working on my local machine and please let me know what are these and where is referring "coteafs.selenium.config" String COTEAFS_CONFIG_KEY = "coteafs.selenium.config"; /**

  1. I have not created any new test cases...just tried with your tests 2.[13:16:37.845] [INFO ] - Starting the browser... (Browser:190) [13:16:37.866] [INFO ] - Setting up Chrome driver... (Browser:190) SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Starting ChromeDriver 2.46.628411 (3324f4c8be9ff2f70a05a30ebc72ffb013e1a71e) on port 30083 Only local connections are allowed. Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code. Jan 22, 2020 1:16:39 PM org.openqa.selenium.remote.ProtocolHandshake createSession INFO: Detected dialect: OSS
WasiqB commented 4 years ago

@MonoAutomation , try writing some tests so you'll understand better. Also read complete README file, it says what coteafs.selenium.config does.

MonoAutomation commented 4 years ago

@WasiqB ,on Firefox its working fine but chrome browser not invoking....chrome driver session is starting but browser not opened Need some info, suppose if I add dataset.yaml config file by creating one more folder repository under resources, do I need to change or write any code or by fault our framework will take care of it.

MonoAutomation commented 4 years ago

Sir, I have verified mysids, parallel run not working , it works only on one browser at a time then run will stop. can you help me how and where I can fix this on your framework?

WasiqB commented 4 years ago

@MonoAutomation , kindly put your project on GitHub and share it's URL. I'll check it out and help you fix the issue.

MonoAutomation commented 4 years ago

Sir,i don't have any separate project..am trying with your project with some additional test cases...what I have observed here if run as testng.xml ...parallel execution is done but if run as seleniumtests not executed..so when ever we want parallel run..then need to choose testing.xml as runner

WasiqB commented 4 years ago

That's how it should be done, because parallel setting is defined in testng.xml file.

MonoAutomation commented 4 years ago

Thank you, I thought we are handling testing.xml through the framework. have on more on report part , I can see we are using epam.reportportal to generate report but after the execution no where the report is getting generated. in this do I need to to any additional setup or configuration?

MonoAutomation commented 4 years ago

Sir, is there way to know current running browser name ...getbrowser()..like..I wanted to check on different methods...plz help

WasiqB commented 4 years ago

What's your use case for getting currently running browser name?

MonoAutomation commented 4 years ago

As a part of parallel execution, I want to know on which browser driver going to perform actions before each class/method

WasiqB commented 4 years ago

I'll check and update you on this.

MonoAutomation commented 4 years ago

Thank you sir

MonoAutomation commented 4 years ago

Sir,Is there any way to read any additional data files to read(.yaml) along with default files(.yaml),I am planning to maintain my test data as well in .yaml files.

under resources/testdata/xxxx.yaml I want to read this data before the class. can you please help in this?