想要使用webdriver获取页面元描述的内容.
让我们说,从DOM下面想要检索文本
Test.com provides a complete software solution for creating online tests and managing enterprise and specialist certification programs, in up to 22 languages
<script src="content/js/jquery.min.js">
<meta content="Test.com provides a complete software solution for creating online tests and managing enterprise and specialist certification programs, in up to 22 languages." name="description">
<meta content="Test.com" name="keywords">
Run Code Online (Sandbox Code Playgroud)
我试过了
System.out.println(driver.findElement(By.xpath("//meta[@name='description']")).getText());
Run Code Online (Sandbox Code Playgroud)
但上面的代码对我不起作用.
最初,xpath 插件在我的 cypress 项目中运行良好。安装了 Typescript 插件并从 javascript 移至 Typescript。现在它开始在 xpath 上抛出错误
Property 'xpath' does not exist on type 'cy & EventEmitter'.ts(2339)
Run Code Online (Sandbox Code Playgroud)
请建议,如何在 Cypress 项目中将 xpath 与 typescript 一起使用? cypress-xpath": "^1.6.2",包含在 package.json 中
package.json文件如下:
"devDependencies": {
"@types/node": "^14.17.8",
"add": "^2.0.6",
"cypress-cucumber-preprocessor": "^4.3.0",
"cypress-mochawesome-reporter": "^2.2.0",
"cypress-xpath": "^1.6.2",
"typescript": "^4.4.3",
"yarn": "^1.22.10"
},
"cypress-cucumber-preprocessor": {
"nonGlobalStepDefinitions": true
}
Run Code Online (Sandbox Code Playgroud) 我添加了网页中的所有链接Arraylist,然后一一点击所有网址。
public class Redirectionlinked1
{
public static List findAllLinks(WebDriver driver)
{
List <WebElement> elementList = new ArrayList();
elementList = driver.findElements(By.tagName("a"));
elementList.addAll(driver.findElements(By.tagName("img")));
List finalList = new ArrayList();
for(WebElement element : elementList)
{
if (element.getAttribute("href") != null)
{
finalList.add(element);
}
}
return finalList;
}
public static void main(String[] args) throws Exception
{
System.setProperty("webdriver.gecko.driver", "E:\\Softwares\\gecko\\geckodriver-v0.16.1-win64\\geckodriver.exe");
System.setProperty("webdriver.chrome.driver", "E:\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.get(" http://testsite.com");
List <WebElement > allImages = findAllLinks(driver);
System.out.println("Total number of elements found " + allImages.size());
driver = new …Run Code Online (Sandbox Code Playgroud) 我喜欢理解'Hive ODBC Connector'的概念.意味着在架构中使用Hive ODBC Connector有什么用处.
是否需要设置DSN(数据源名称).我们可以进行无DSN配置吗?
请详细说明
使用 RobotFramework,
我正在尝试使用 FOR 循环检索 Webelements 标签。
${temp}= Get WebElements xpath=//*[@class='ui-grid-canvas']
Set Global Variable ${temp}
${as} Get Element Count xpath=//*[@class='ui-grid-canvas']
: FOR ${ELEMENT} IN ${temp}
\ ${as}= Get Text ${ELEMENT}
Run Code Online (Sandbox Code Playgroud)
我在 FOR 循环中出错。请纠正我。
AttributeError: 'list' object has no attribute 'startswith'
Run Code Online (Sandbox Code Playgroud) selenium ×3
java ×2
webdriver ×2
xpath ×2
arrays ×1
cypress ×1
cypress-cucumber-preprocessor ×1
hadoop ×1
hive ×1
odbc ×1
python ×1
robots.txt ×1
typescript ×1