java增加li标签,如何在java上使用selenium webdriver动态创建li标签

Here is my ol tag

  1. testing page2

I want to insert this below tag to above ol tag as 3rd element using selenium webdriver in java

testing page3

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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值