如何点击'新< div>'点击一个按钮后新生成的?在C#硒 [英] how to click on 'new <div>' which newly generates after clicking on a button? in C# selenium

查看:214
本文介绍了如何点击'新< div>'点击一个按钮后新生成的?在C#硒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在点击按钮之前,页面的html代码位于

 < div id =layerContainer>> ; < / DIV> 

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

也许这种方法可以帮到你。


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.

这篇关于如何点击'新&lt; div&gt;'点击一个按钮后新生成的?在C#硒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆