Selenium webdriver window handles c# switchTo failed

后端 未结 5 1206
广开言路
广开言路 2021-02-10 02:11

Here comes 2 windows pop out during the testing.

my code:

string BaseWindow = driver.CurrentWindowHandle;                 
ReadOnlyCollection

        
5条回答
  •  有刺的猬
    2021-02-10 02:38

    1. Using the original post code.

      string existingWindowHandle = driver.CurrentWindowHandle;

      Its the first window.

    2. One important thing is:

      ReadOnlyCollection windowHandles = driver.WindowHandles

      Contains the string name object, not the Windows Title Name, for example Collection windowHandles could contains:

      Not Windows Title Name as {Menu},{PopUp}
      It contains: {45e615b3-266f-4ae0-a508-e901f42a36d3},{c6010037-0be6-4842-8d38-7f37c2621e81}

提交回复
热议问题