VBA to find if an element contains certain texts

▼魔方 西西 提交于 2020-06-28 03:37:14

问题


I'm new to Selenium and VBA. What i want to do is automate selection of a certain TEXT in a CSS. Selenium brings me this:

css=.x-grid3-row:nth-child(42) .x-grid3-col:nth-child(4) > .x-grid3-cell-inner

Everyting would be fine, except the TEXT I want to select sometimes move to different grid3-row:nth-child What I want to achieve is to find in which x-grid3-row:nth-child the desired TEXT is so I could click it with a VBA bot.

Thank you for your help.


回答1:


You won't be able to construct a css-selectors passing the desired text.

You can find a relevant detailed discussion in selenium.common.exceptions.InvalidSelectorException with “span:contains('string')”

As an alternative you can use a xpath based Locator Strategy as follows:

driver.FindElementByXPath("//*[@class='x-grid3-cell-inner' and text()='certain_text']")


来源:https://stackoverflow.com/questions/62532038/vba-to-find-if-an-element-contains-certain-texts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!