-1

I want to download the video, but there is a problem
I am trying to close popped up

enter image description here

the code i used has not worked
this is my code

Sub Close_Pop_up()
    With New ChromeDriver
        .Get "https://snaptik.app/en/"
        .FindElementById("url").SendKeys ("https://www.tiktok.com/@funny_v.i.p/video/7020796826760547590")
        .FindElementById("submiturl").Click
        .FindElementByXPath("/html/body/main/section[2]/div/div/article/div[2]/div/a[1]/span/span").Click
        .SwitchToFrame .FindElementByTag("iframe", TimeOut:=10000)
        .FindElementById("dismiss-button").Click
    End With
End Sub

this is the html code

<div class="ns-dws4v-e-6 close-button" id="dismiss-button" x-ns-dws4v-e="6" x-overflow-forbidden="xy" aria-label="Close ad" tabindex="1"><div class="ns-dws4v-e-7 close-text" x-ns-dws4v-e="7"><span class="ns-dws4v-e-8" dir="auto" x-ns-dws4v-e="8" x-score="1">Close</span></div></div>

can anyone give a good idea ?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
anggun
  • 73
  • 2
  • 5

1 Answers1

0

There are total 12 ifames within the page and you need to identify the specific iframe you intend to switch.

Solution

Sub Close_Pop_up()
    With New ChromeDriver
    .Get "https://snaptik.app/en/"
    .FindElementById("url").SendKeys ("https://www.tiktok.com/@funny_v.i.p/video/7020796826760547590")
    .FindElementById("submiturl").Click
    .FindElementByXPath("/html/body/main/section[2]/div/div/article/div[2]/div/a[1]/span/span").Click
    .SwitchToFrame "ad_iframe"
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352