how to click on 'new
' which newly ge

2019-03-03 22:50发布

问题:

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.