关于页面元素不能定位,通过Js进行处理

Posted jackyu126

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于页面元素不能定位,通过Js进行处理相关的知识,希望对你有一定的参考价值。

public class Test {
public static void main(String[] args) throws Exception {
File file = new File("C:\\Users\\HP\\AppData\\Roaming\\Mozilla\\Firefox\\Profiles\\y0iw24je.default");
FirefoxProfile profile = new FirefoxProfile(file);
WebDriver driver = new FirefoxDriver(profile);
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(60, TimeUnit.SECONDS);
................................................
WebElement element = driver.findElement(By.cssSelector("select[id=‘programType‘]"));
javascriptExecutor js = (JavascriptExecutor)driver;
js.executeScript("document.getElementById(‘programType‘).value=‘1‘");
js.executeScript("document.getElementById(‘orderStatus‘).value=‘PASS,SUPPLY‘");
js.executeScript("document.getElementById(‘queryBtn‘).click()");--js实现点击世间onclick()/click
Thread.sleep(3000);
}
}
















以上是关于关于页面元素不能定位,通过Js进行处理的主要内容,如果未能解决你的问题,请参考以下文章

元素focus页面不滚动不定位的JS处理

基于python实现UI自动化5. selenium实现获取页面元素属性(内容标题URL浏览器名称等)

基于python实现UI自动化5. selenium实现获取页面元素属性(内容标题URL浏览器名称等)

基于python实现UI自动化5. selenium实现获取页面元素属性(内容标题URL浏览器名称等)

selenium IDE 如何定位页面变动元素

selenium怎么定位页面元素