您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

创建 css 表达式有哪些不同的方法?

2024/6/26 13:19:23发布21次查看
下面列出了创建 css 表达式的不同方法 -
使用类作为 css 选择器
这将选择所有该特定类的网络元素。 (用 (.) 表示,例如 - .classname)
使用 id 作为 css 选择器。
这将选择该特定 id 的 web 元素。 (例如用 (#) 表示 - #id)
使用标记名和属性值作为选择器。
这将选择该对象的 web 元素特定的属性值组合。 (由标记名[attribute='value']表示)
示例import org.openqa.selenium.by;import org.openqa.selenium.keys;import org.openqa.selenium.webdriver;import org.openqa.selenium.webelement;import org.openqa.selenium.chrome.chromedriver;import java.util.concurrent.timeunit;public class cssexpression { public static void main(string[] args) { system.setproperty("webdriver.chrome.driver", "c:\users\ghs6kor\desktop\java\chromedriver.exe"); webdriver driver = new chromedriver(); string url = "https://www.tutorialspoint.com/index.htm"; driver.get(url); driver.manage().timeouts().implicitlywait(12, timeunit.seconds); //using class with . for css expression driver.findelement(by.cssselector(".gsc- input")).sendkeys("selenium"); driver.close(); }}
示例import org.openqa.selenium.by;import org.openqa.selenium.keys;import org.openqa.selenium.webdriver;import org.openqa.selenium.webelement;import org.openqa.selenium.chrome.chromedriver;import java.util.concurrent.timeunit;public class cssid { public static void main(string[] args) { system.setproperty("webdriver.chrome.driver", "c:\users\ghs6kor\desktop\java\chromedriver.exe"); webdriver driver = new chromedriver(); string url = "https://www.tutorialspoint.com/index.htm"; driver.get(url); driver.manage().timeouts().implicitlywait(12, timeunit.seconds); //using id with # for css expression driver.findelement(by.cssselector("#gsc-i- id1")).sendkeys("selenium"); driver.close(); }}
示例import org.openqa.selenium.by;import org.openqa.selenium.keys;import org.openqa.selenium.webdriver;import org.openqa.selenium.webelement;import org.openqa.selenium.chrome.chromedriver;import java.util.concurrent.timeunit;public class csstagexp { public static void main(string[] args) { system.setproperty("webdriver.chrome.driver", "c:\users\ghs6kor\desktop\java\chromedriver.exe"); webdriver driver = new chromedriver(); string url = "https://www.tutorialspoint.com/index.htm"; driver.get(url); driver.manage().timeouts().implicitlywait(12, timeunit.seconds); //using id tagname attribute combination for css expression driver.findelement(by.cssselector("input[name=’search’]")). sendkeys("selenium"); driver.close(); }}
以上就是创建 css 表达式有哪些不同的方法?的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product