I have an issue to accept a cookie alert on the below website which is embedded in an iframe:
I've tried many ways to solve the issue with using the driver.switchTo().frame()
- method:
- by using the Id of the iframe
sp_message_iframe_234327
- by inserting an index for the iframe
0
- by calling the iframe through a WebElement
WebElement element = driver.findElement(By.xpath("//body/div[6]/iframe[@src='https://cdn.privacy-mgmt.com/index.html?message_id=234327&consentUUID=b2cb90ea-dfdd-4655-b6b9-89117ff34893&requestUUID=ccb96546-c6b5-44e7-9869-438b32f7ad89&preload_message=true']")); driver.switchTo().frame(element);
Unfortunately none of them are working. I'm always getting the following exception:
org.openqa.selenium.NoSuchFrameException
Does anyone have an idea on this specific example to switch on the iframe properly? I'm working with Selenium WebDriver 3.141.59 on Java and my tests should be executed on Mozilla Firefox (80.0.1) and Chromium (85.0.4183.102). Those two browsers are launched headlessly. Glad for any help.