0

I'm trying to click on the banner Administration

<div class="wah-global-ask-banner-item-container5 wah-clickable wah-provider-launch" data-provider="admin-link" id="admin-banner">
 <div class="wah-global-ask-banner-item">
 <div class="wah-global-ask-banner-item-icon-container-small" style="">
 <div class="wah-global-ask-banner-item-icon iconMonitor128" style="zoom: 50%;"></div></div>
 <div class="wah-global-ask-banner-item-title wah-global-ask-banner-item-title-paa" style="top: 52px; left: 0px; font-size: 24px;">Administration</div>

I already tried using find_element_by_class_name() and it didn't work.

How can I do it?

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
Luiz
  • 41
  • 1
  • 8
  • What didn't work? Was element not found? Are you just looking for a locator that works? The html snippet is a bit unclear on what's nested in which div – DMart Sep 20 '19 at 01:25

2 Answers2

1

You can use CssSelector:

FindElement(By.CssSelector(".wah-global-ask-banner-item-title.wah-global-ask-banner-item-title-paa"));

There is a nice extension for Chrome which helps you determine the best CSS Selectors to locate elements called CSS Selector Helper for Chrome

1

To click() on the element with text as Administration you have to induce WebDriverWait for the desired ElementToBeClickable() and you can use either of the following Locator Strategies:

  • CssSelector:

    new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("div.wah-global-ask-banner-item div.wah-global-ask-banner-item-title.wah-global-ask-banner-item-title-paa"))).Click();
    
  • XPath:

    new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//div[@class='wah-global-ask-banner-item-title wah-global-ask-banner-item-title-paa' and text()='Administration']"))).Click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352