Ivar
Ivar

Reputation: 3

Webdriver: finding and clicking hidden element, where id constantly changing

i am newbie to selenium webdriver, i am struggling to find a button on the webpage, because its Id is constantly changing and there is no other attributes available to use to identify this element. please see below code. could someone look at this code and help me how to identify this button element.

selenium webdriver hidden elements

Upvotes: 0

Views: 863

Answers (1)

Saurabh Gaur
Saurabh Gaur

Reputation: 23815

You should try by xPath as below :-

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();

Be sure this element is not inside a frame..

Hope it will help you..:)

Upvotes: 1

Related Questions