locked
How can I open 3 same browsers using Selenium Grid RRS feed

  • Question

  • I want to open total 15 nodes, first 3 will run on chrome next 3 will run on firefox. code is
    using selenium Grid.
    package grid;
    
    
        import java.net.MalformedURLException;
        
        import java.net.URL;
        import java.net.UnknownHostException;
        
        import org.openqa.selenium.Platform;
        import org.openqa.selenium.WebDriver;
        import org.openqa.selenium.chrome.ChromeDriver;
        import org.openqa.selenium.chrome.ChromeOptions;
        import org.openqa.selenium.remote.DesiredCapabilities;
        import org.openqa.selenium.remote.RemoteWebDriver;
        
        public class ChromeGridTest {
        
            public static void main(String[] args) throws MalformedURLException  {
                
                //SwitchClass.main(args);
                
                
                //Define desired capabilities
                DesiredCapabilities cap=new DesiredCapabilities();
                cap.setBrowserName("chrome");
                cap.setPlatform(Platform.WINDOWS);
                
                //Chrome option  
                ChromeOptions options = new ChromeOptions();
                options.merge(cap);
                options.setHeadless(false);
                
                //Hub URL
                String huburl = "http://URL:4444/wd/hub";
                 
                // Create driver with hub address and capability
               WebDriver driver=new RemoteWebDriver(new URL(huburl), options);
                
                //Test case
                System.out.println("Title is "+driver.getTitle());
                
                
                
                driver.close();
            }
        }

    First I need to get the ip of nodes after taht i need to apply switch by giving MachineIP on which machine it has to run 3 browsers of chrome etc. How Can I do that? I am using selenium eclipse IDE.
    Thursday, July 2, 2020 4:53 PM

All replies

  • Hi Mehwish,

    Welcome to MSDN forum.

    I think your issue is more related to use Selenium grid, so I recommend you go to Stack Overflow tagged with Selenium grid and start a new thread to seek for a more professional help.

    Hope this helps.

    Best Regards,

    Tianyu


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, July 3, 2020 5:43 AM