1. 程式人生 > >關於頁面元素不能定位,通過Js進行處理

關於頁面元素不能定位,通過Js進行處理

pass timeunit nds def 行處理 static second tex new

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進行處理