简体   繁体   English

如何点击“新 <div> &#39;单击按钮后,哪个新生成? 在C#硒中

[英]how to click on 'new <div>' which newly generates after clicking on a button? in C# selenium

before i clicking the button, the html code for the page is below 在我单击按钮之前,页面的html代码在下面

<div id="layerContainer"> </div>

but after clicking a button, than the code appears like picture here 但是单击按钮后,代码显示为此处的图片

I tried to find the new button, but always "unable to find element ~@" ] 我试图找到新按钮,但始终“无法找到元素〜@”]

wait.Until(ExpectedConditions.ElementExists(By.XPath("//*[@id='layerContainer']/div/section/div/div[2]/form/article/footer/div/button")));
IWebElement submit2 = this.driver.FindElement(By.XPath("//*[@id='layerContainer']/div/section/div/div[2]/form/article/footer/div/button"));
submit2.Click();

my purpose is to find out the newly generated button and click on it, but it fails to find out the new button all the time, is there any way to solve it? 我的目的是找出新生成的按钮并单击它,但是它始终无法找到新按钮,有什么办法可以解决?

You can click the button according to the coordinates. 您可以根据坐标单击按钮。

For example: 例如:

在此处输入图片说明

Actions action = new Actions(driver);
action.MoveToElement(driver.FindElement(By.Id("layerContainer")), 97, 272).Click().Perform();

Maybe this method will help you. 也许这种方法会帮助您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM