I am currently trying to automate the input into a form on a website, but i cant seem to find a way to select the dropdown.
The request is sent.
When finished working inside the iframe don't forget to switch to the default content with:
driver.switch_to.default_content()
CodePudding user response:
The <nz-select>
element is within an iframe so you have to:
Induce WebDriverWait for the frameToBeAvailableAndSwitchToIt.
Induce WebDriverWait for the desired elementToBeClickable.
You can use the following locator strategies:
driver.get("https://immosuche.degewo.de/de/properties/W1400-40660-0750-0902.html"); new WebDriverWait(driver, Duration.ofSeconds(10), Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.cssSelector("button#cookie-consent-submit"))).click(); new WebDriverWait(driver, Duration.ofSeconds(10), Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.xpath("//p[contains(., 'degewo Marzahner Wohnungsgesellschaft mbH')]//following::div[1]//span[text()='Kontaktieren']"))).click(); new WebDriverWait(driver, Duration.ofSeconds(10)).until(ExpectedConditions.frameToBeAvailableAndSwitchToIt(By.cssSelector("iframe[src^='https://app.wohnungshelden.de/public/listings']"))); WebElement elem = new WebDriverWait(driver, Duration.ofSeconds(10), Duration.ofSeconds(10)).until(ExpectedConditions.elementToBeClickable(By.xpath("//nz-select[@nzplaceholder='Bitte auswählen']//div[@nz-select-top-control]"))); ((JavascriptExecutor)driver).executeScript("arguments[0].click();", elem);
Browser Snapshot: