0

I am working with C# selenium as an amateur. How can I select the country on the site below. I tried many things but I couldn't choose.

Url: " https://support.google.com/legal/contact/lr_counternotice?product=websearch "

Snapshot of the element:

enter image description here

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
iaydemir
  • 13
  • 2

1 Answers1

0

To click on the <li> element with text Afghanistan you have to induce WebDriverWait for the ElementToBeClickable() and you can use either of the following Locator Strategies:

  • CssSelector:

    new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("div.sc-select[aria-label^='Country of residence']"))).Click();
    new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("ol.sc-select-show li[id=':2']"))).Click();
    
  • XPath:

    new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//div[@class='sc-select' and starts-with(@aria-label, 'Country of residence')]"))).Click();
    new WebDriverWait(driver, TimeSpan.FromSeconds(20)).Until(ExpectedConditions.ElementToBeClickable(By.XPath("//ol[@class='sc-select-show']//li[text()='Afghanistan']"))).Click();
    
undetected Selenium
  • 183,867
  • 41
  • 278
  • 352