Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/306.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# selenium with ng hide不允许我单击并给出可见性错误_C#_Selenium Webdriver - Fatal编程技术网

C# selenium with ng hide不允许我单击并给出可见性错误

C# selenium with ng hide不允许我单击并给出可见性错误,c#,selenium-webdriver,C#,Selenium Webdriver,所以我有两个按钮,一个出现在pc浏览器上,一个出现在移动浏览器上,我正在尝试单击一个 <button class="A otherclasses" ng-hide="isMobile">Button A</button> <button class="B otherclasses ng-hide" ng-hide="!isMobile">Button B</button> 我使用以下代码获取了一个示例: IWebElement目标= _drive

所以我有两个按钮,一个出现在pc浏览器上,一个出现在移动浏览器上,我正在尝试单击一个

<button class="A otherclasses" ng-hide="isMobile">Button A</button>
<button class="B otherclasses ng-hide" ng-hide="!isMobile">Button B</button>
我使用以下代码获取了一个示例:

IWebElement目标= _driver.FindElementBy.CssSelectorbutton[ng hide=\isMobile\]; 线程500; 目标。点击

我还试着用.ClassName来抓它,但还是没有成功 测试在Visual Studio C中进行。 司机是铬合金的。 我试图避免引用文本“Button A”,因为它会根据语言发生变化。 我一直在谷歌上搜索和摸索,即使我能在视觉上看到它,我也抓不到一个

你试过了吗

_driver.FindElement(By.CssSelector("button:not(.ng-hide)")).Click();

您是否尝试过javascript executor?我尝试过它的变体,但无法使其正常工作,可能是我没有使用正确的参数,因为大多数示例都用于style=display:none您是否尝试过xpath//button[text='button A']是否可以避免文本部分?因为文本会根据语言而改变。我仍然会收到以下不可见错误:_driver.FindElement By.XPath//button[text='button A']。单击;
_driver.FindElement(By.CssSelector("button:not(.ng-hide)")).Click();