Home > Back-end >  How to click on send button on whatsapp using Selenium xpath or css in vb.net
How to click on send button on whatsapp using Selenium xpath or css in vb.net

Time:07-25

How can use whatsapp xpath or css(Chromedriver) in vb.net.

HTML:

<span data-testid="send" data-icon="send" class>...</span> ==$0

xpath:

//*[@id="main"]/footer/div[1]/div/span[2]/div/div[2]/div[2]/button/span

I tried but not working:

driver.FindElement(By.CssSelector("span[data-testid='send' data-icon='send']")).Click()

CodePudding user response:

it should be like

driver.FindElement(By.CssSelector("span[data-testid='send'][data-icon='send']")).Click()

when select specific attributes :

span[data-testid='send']

to add attributes to same tag :

span[data-testid='send'][data-icon='send']

*no space between attributes

CodePudding user response:

As per the HTML:

<span data-testid="send" data-icon="send" class>...</span>

To click on the element you can use either of the following Locator Strategies:

  • Using FindElementByCss:

    Driver.FindElementByCss("span[data-testid='send'][data-icon='send']").Click()
    
  • Using FindElementByXPath:

    Driver.FindElementByXPath("//span[@data-testid='send' and @data-icon='send']").Click()
    

References

You can find a couple of relevant detailed discussions in:

  • Related