Webdriver:查找并单击隐藏元素,其中 id 不断变化
Webdriver: finding and clicking hidden element, where id constantly changing
我是 selenium webdriver 的新手,我很难在网页上找到一个按钮,因为它的 Id 不断变化并且没有其他属性可用于识别此元素。请看下面的代码。
谁能看看这段代码并帮助我如何识别这个按钮元素。
您应该按以下 xPath
尝试 :-
WebDriverWait wait = new WebDriverWait(driver, 1000);
WebElement el = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xPath("//div[contains(@class, 'header-navigation__cta-buttons-wrapper')]/a[contains(@class, 'cta-buttons__link--button-1')]")));
el.click();
确保此元素不在框架内..
希望对你有所帮助..:)
我是 selenium webdriver 的新手,我很难在网页上找到一个按钮,因为它的 Id 不断变化并且没有其他属性可用于识别此元素。请看下面的代码。 谁能看看这段代码并帮助我如何识别这个按钮元素。
您应该按以下 xPath
尝试 :-
WebDriverWait wait = new WebDriverWait(driver, 1000);
WebElement el = wait.until(ExpectedConditions.visibilityOfElementLocated(By.xPath("//div[contains(@class, 'header-navigation__cta-buttons-wrapper')]/a[contains(@class, 'cta-buttons__link--button-1')]")));
el.click();
确保此元素不在框架内..
希望对你有所帮助..:)