Here is my ol tag
-
page2
I want to insert this below tag to above ol tag as 3rd element using selenium webdriver in java
How can i do it?
解决方案
Webdriver is designed for browser automation, not for changing server side code or HTML returned by the server. However, if you want to change the HTML temporarily on the client side, you'll have to do what everyone else does and run some JavaScript on the browser.
As the Selenium FAQ states, you can execute JavaScript with a WebDriver instance by casting it into a JavascriptExecutor:
WebDriver driver; // Assigned elsewhere
JavascriptExecutor js = (JavascriptExecutor) driver;
js.executeScript("return document.title");
Then you can use JavaScript to manipulate the DOM inside the page being shown on the browser that your WebDriver instance is currently driving.