Not able to close the Chat Window | Selenium Training|Java|WebDriver|TestNG|Frameworks|Videos
10% May Month Discount Avail now

Selenium Training Forum

Not able to close the Chat Window

V
Vinay Krishna Post on 10/03/2019

Hello Sir,

I am not able to close the chat window in the below website. This chat window appears after 10 seconds of the website launch. Looks like this is an Iframe. i am looking to close this chat window before i proceed with other steps, script was failing if this window appears in between.

below is the code i tried and it is not working.

website : https://www.indianeagle.com

int iframeCount = driver.findElements(By.tagname("iframe")).size(); // this is giving count as 7

     Note :

             1. int iframeCount = driver.findElements(By.xpath("//iframe")).size(); //with this i am getting count as 9 - why is that difference                      in count.

            2. when i go to page source and search with text iframe i see only 2 occurences. 

 

i tried iterating from 0 to iframeCount - each time i am switching to new iframe with index number and searching for the particular element to make sure that is chat window i want to close.

but when the index count is 1 - execution is geting aborted saying iframe does not exist.

can you pls check and let me know how to handle this scenario.

 

D

Instructor

Demo Reply on 12/03/2019

See, there are different possibilities for Xpaths. Make up your own Custom XPath, retrieve the element and then try again

V
Vinay Krishna Reply on 13/03/2019

i can create my xpaths but to work on that object i need to move to that iframe rt ? how do we do that in this case ?

D

Instructor

Demo Reply on 14/03/2019

you can use the web element method instead of the index method to retrieve the frame

V
Vinay Krishna Reply on 30/03/2019

Thank you, this can be closed