Question selenium webdriver run only one instance

james2722

New member
Joined
Jul 28, 2018
Messages
3
Programming Experience
Beginner
i want to access Form1 class Selenium from another class but problem here is whenever access to Form1 selenium another instance execute. i only want to use only one instance . anyone enlighten me much appreciate

VB.NET:
Public Class Form1
        Public service As ChromeDriverService = ChromeDriverService.CreateDefaultService
        Public chromeOptions As New OpenQA.Selenium.Chrome.ChromeOptions()
        Public  driver As New OpenQA.Selenium.Chrome.ChromeDriver(chromeOptions)
    
        Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles btnCollect.Click
            ' i only want to run one webdriver session not multiple session.
            Monitoring.test()
            Monitoring2.test2()
            
        End Sub
    end class
    
    Public Class Monitoring
        public sub test()
             driver.Navigate().GoToUrl("https://www.google.com")
        end sub
    
    end class
    
    Public Class Monitoring2
        public sub test2()
             driver.Navigate().GoToUrl("https://www.yahoo.com")
        end sub
    
    end class
 

jmcilhinney

VB.NET Forum Moderator
Staff member
Joined
Aug 17, 2004
Messages
14,314
Location
Sydney, Australia
Programming Experience
10+
I don't see any code there that is accessing Form1 at all. If you want us to help with some code that is not working as you expect then it's generally a good idea to show us that code. ESP doesn't work well over the internet.
 

james2722

New member
Joined
Jul 28, 2018
Messages
3
Programming Experience
Beginner
I don't see any code there that is accessing Form1 at all. If you want us to help with some code that is not working as you expect then it's generally a good idea to show us that code. ESP doesn't work well over the internet.
hi..first of all i'm almost new to programming world sorry.
what i encountered problem is when i hit button1 on the form it execute Monitoring.test() and Monitoring2.test but it open two seprate window webpage which is yahoo.com and google.com

i only want to use one webpage window session so firstly i open google.com after that i want to open yahoo.com sequentially .
sorry my bad english
 

james2722

New member
Joined
Jul 28, 2018
Messages
3
Programming Experience
Beginner
hi..first of all i'm almost new to programming world sorry.
what i encountered problem is when i hit button1 on the form it execute Monitoring.test() and Monitoring2.test but it open two seprate window webpage which is yahoo.com and google.com

i only want to use one webpage window session so firstly i open google.com after that i want to open yahoo.com sequentially .
sorry my bad english
anybody know?
 
Top Bottom