Here sharing the HTML and xpath code what I wrote. But the click event is not working.
<div role="button" class="U2GHA6fgb BHYSYYBxpf" aria-label="Add food" aria-disabled="false" data-tooltip="Add food">
<span class="DPvwYc" aria-hidden="true">icon</span>
I am setting xpath as like below. But the click event not working
var xpath1 = "//div[contains(@role,\"button\") and contains(@aria-label,\"Add food\")]"
webDriver.findElement<WebElement>(By.xpath(xpath1)).click()
You can use the following xpath based Locator Strategy:
var xpath1 = "//div[@aria-label='Add food' and data-tooltip='Add food']/span"
webDriver.findElement<WebElement>(By.xpath(xpath1)).click()