Can you tell me whether we should use web switch window in this case?

Hello, I want to capture the details of all villa in particular location such as lonavla through the airbnp website .
I search the lonavla in airbnp site and get the result. When I click on first result (see snapshot)

it open’s new tab and this new tab contain the all the information that I want extract.


When I am trying to extract this using xpath it gives error unable to find element. Although it is current opened tab.
when I tried with web switch window it is able to extract.

As it opens in newtab and becomes the current working tab then it should be able to extract but was not able to extract.
so in this case it is mandatory to use web switch window?

Hi Shubham,

Yes, you have to use the Web Switch Window to extract the data from the newly opened tab/window.

When you click on any element which results in a new tab/window, the selenium cursor didn’t move and still points to the old window. To move the cursor to a new tab/window you have to use Web Switch Window.

1 Like