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

不问归期 提交于 2019-12-02 15:05:43

问题


before i clicking the button, the html code for the page is below

<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?


回答1:


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.



来源:https://stackoverflow.com/questions/40220377/how-to-click-on-new-div-which-newly-generates-after-clicking-on-a-button-in

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