
下面列出了创建 css 表达式的不同方法 -
使用类作为 css 选择器
这将选择所有该特定类的网络元素。 (用 (.) 表示,例如 - .classname)
使用 id 作为 css 选择器。
立即学习“前端免费学习笔记(深入)”;
wechat-miniprogram-plugin是基于JetBrains平台的微信小程序插件。主要功能wxml/wxss/wxs文件支持语法解析代码完成代码高亮wxml嵌入表达式支持wxml 标签支持wxml提取自定义组件创建微信小程序组件以及页面相关文件导航微信小程序自定义组件支持自动注册自定义组件组件配置解析重命名小程序自定义组件或页面同时移动自定义组件或页面的所有文件微信小程序配置文件支持
3
这将选择该特定 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 表达式有哪些不同的方法?的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号