简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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