Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/260.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# 等待模态被定位_C#_Selenium_Selenium Webdriver_Selenium Chromedriver_Selenium Grid - Fatal编程技术网

C# 等待模态被定位

C# 等待模态被定位,c#,selenium,selenium-webdriver,selenium-chromedriver,selenium-grid,C#,Selenium,Selenium Webdriver,Selenium Chromedriver,Selenium Grid,我在检测模态是否处于我正在使用的位置时遇到问题 wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable((WEAsesor.BtnColumnas))).Click(); 但是模态有一个上升的效果,直到到达它的位置,指令检测到模态何时在DOM中,但我无法对元素执行任何操作,因为还没有到达这个位置,您知道如何解决这个问题吗?您可以这样编写自定义等待实现: wait.Until(element =&

我在检测模态是否处于我正在使用的位置时遇到问题

wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementToBeClickable((WEAsesor.BtnColumnas))).Click();
但是模态有一个上升的效果,直到到达它的位置,指令检测到模态何时在DOM中,但我无法对元素执行任何操作,因为还没有到达这个位置,您知道如何解决这个问题吗?

您可以这样编写自定义等待实现:

wait.Until(element => /* Do something with the element */);
所以,如果你想等待一个位置,你可能应该先(用手)等待,看看你想要的位置是什么。例如:

int expectedLocationX = WEAsesor.BtnColumnas.Location.X;
int expectedLocationY = WEAsesor.BtnColumnas.Location.Y;
知道元素的预期位置后,编写等待:

/* you set whatever the X or Y is, in this example, 10 */
int expectedLocationX = 10; 
int expectedLocationY = 10; 
wait.Until(driver => 
{
    bool isXCorrect = WEAsesor.BtnColumnas.Position.X == expectedLocationX;
    bool isYCorrect = WEAsesor.BtnColumnas.Position.Y == expectedLocationY;

    /* This code will return *true* only if both the X and Y are correct.*/
    return isXCorrent && isYCorrect;
});
本质上,
wait.Until(driver=>…)
方法说,“在这里,如果你想使用驱动程序,做你的事情,当你想让我停止等待时返回true。如果你返回false或null,我将继续运行
,直到你返回true或非null


因此,您告诉
wait
对象等待元素到达预期位置。

欢迎使用So!您可能应该为上下文添加更多代码,以便我们可以更好地帮助您