I have tried several ways now to quit my selenium driver, at any point I want. This includes testing several timer combinations, extended classes methods and more. What seems to be almost working so far is to use the following code snippet: while (ugg== true)
. Now I obviously have the problem that it will loop through my process and keeps opening new browser instances. I would like to therefore additionally use an statement which makes my code only execute if there is less than one driver instance running. How would I accomplish this? I know for WebElements there is a .Count
option. I came up with if (ugg== true && driver == 0)
, but this doe not work.
If you have a solution no matter in regards to my while
statement or another way, I would appreciate it.
my two angles:
if (ugg== true && driver == 0)
{
// do something
}
while (ugg == true && driver == 0)
{
// do something
}
CodePudding user response:
driver
is an object, not an int
.
So, instead of driver == 0
try driver == null
.
So, your code could be something like
if (ugg== true && driver == null)
{
// do something
}