selenium

How to extract the text from the search results of duckduckgo using Selenium Python

﹥>﹥吖頭↗ 提交于 2021-02-05 08:09:12
问题 I am trying to get the link descriptions of duckduck of search results using the following: results=browser.find_elements_by_xpath("//div[@id='links']/div/div/div[2]") description=[] for result in results: description.append(result.text) I am getting the error 'list' object has no attribute 'text'. I was able to use a similar method to get the search result titles, but for some reason I am unable to extract the text from this particular xpath. 回答1: To extract the link descriptions of the

java.lang.ClassCastException: java.base/java.lang.String cannot be cast to org.openqa.selenium.WebElement when executing test through Selenium

只谈情不闲聊 提交于 2021-02-05 08:09:05
问题 I'm trying make an automation test in Selenium WebDriver, but Eclipse is showing me the following error: java.lang.ClassCastException: java.base/java.lang.String cannot be cast to org.openqa.selenium.WebElement Here is my code: public void SeachApp() { Object elem = driver.getPageSource().contains("Staffing"); if (elem != null) { System.out.println("Encontrado"); int width = ((WebElement) elem).getSize().getWidth(); Actions act = new Actions(driver); act.moveToElement((WebElement) elem)

Selenium C# How to handle Alert “Open Pick an app”?

[亡魂溺海] 提交于 2021-02-05 08:08:53
问题 I am trying to get the Alert's Text using Selenium C# for Chrome But this alert seems different from a normal JavaScript Alert, using the code below returns an error exception: string text = driver.SwitchTo().Alert().Text; OpenQA.Selenium.NoAlertPresentException: no such alert Is this considered as an alert? Is there a way to handle it? 回答1: The dialog you're seeing is shown on the OS level so there's no way for you to see that in the DOM or use Selenium to interact with it. If you really

Automate Ember.js application using Selenium when object properties are changed at run-time

本秂侑毒 提交于 2021-02-05 07:57:06
问题 I am trying to automate an Ember.js application using Selenium+TestNg. The drop-down in the application has only one object property id. However every time i refresh the Page id gets change and there is not pattern. Eg: First time i open a page id=ember1398 and when i refresh the page same object id changes to ember1097. I would be greatful if some one can guide me in overcoming this challenge. I am open to change tool/framework if necessary. 回答1: This is a known issue with Ember. We work

selenium web driver element click not working in windows 10

此生再无相见时 提交于 2021-02-05 07:55:09
问题 I am using selenium webdriver for automation tool creation in C#. That automation working fine windows 7, but not working windows 10. ex. driver.FindElement(By.XPath("//button[@type='submit']")).Click(); Click not working. error msg. threw an exception of type 'OpenQA.Selenium.WebDriverException' base: {"The HTTP request to the remote WebDriver server for URL http://localhost:7057/hub/session/c335c107-a5ba-48a1-8858-58de998c62dc/element/%7B0678bf84-d09c-43d4-a4cf-ea35f73168a8%7D/click timed

How to get all text from different elements under one div

孤人 提交于 2021-02-05 07:51:32
问题 I have problem, here is html pseudocode: <div class="content" id="ui6" role ="tabpanel"> <p> text </p> <ul> <li> text2 </li> <li> text3 </li> </ul> </div> I want to get text, text2 and text3 and print them, but I can only manage to get "text". Here is the code: List<WebElement> sectionThreeText = driver.findElements(By.cssSelector("#ui6")); for(WebElement e : sectionThreeText) { System.out.println(e.getText()); } I tried also find it by: css = "#ui6 > p ul" xpath = "//*[@id=ui6]" xpath = "//*

Cannot cast from List<Functions.Function1<Object,String>> to List<String> creating a list from list of WebElements using Selenium and stream() Java8

狂风中的少年 提交于 2021-02-05 07:49:51
问题 I'm trying to read an HTML table and get all the values into a 2d list using selenium. I'm using streamable to create a List inside another map() method. But I get Cannot cast from List<Functions.Function1<Object,String>> to List<String> error at nested collect method's line HTML: +--------+-------+ | r1 v1 | r1 v2 | +--------+-------+ | r2 v1 | r2 v2 | +--------+-------+ <html> <body> <table> <tbody> <tr> <td> <div> <span>r1 v1</span> </div> </td> <td> <div> <span>r1 v2</span> </div> </td> <

Cannot cast from List<Functions.Function1<Object,String>> to List<String> creating a list from list of WebElements using Selenium and stream() Java8

巧了我就是萌 提交于 2021-02-05 07:49:08
问题 I'm trying to read an HTML table and get all the values into a 2d list using selenium. I'm using streamable to create a List inside another map() method. But I get Cannot cast from List<Functions.Function1<Object,String>> to List<String> error at nested collect method's line HTML: +--------+-------+ | r1 v1 | r1 v2 | +--------+-------+ | r2 v1 | r2 v2 | +--------+-------+ <html> <body> <table> <tbody> <tr> <td> <div> <span>r1 v1</span> </div> </td> <td> <div> <span>r1 v2</span> </div> </td> <

PhantomJS can't load correctly web page

纵然是瞬间 提交于 2021-02-05 07:48:07
问题 I'm currently trying to scrape a web page with PhantomJS and Selenium (python 2.7.9 on Windows 7) but PhantomJS fail to load correctly the web page. If I use Firefox as webdriver I have no problem to see the page as I want. At first I thought it was a javascript problem (page-side) since with save_screenshot I could see what normally the page shows when javascript is disabled, but if I disable javascript the page show me correctly that "Javascript must be enabled", so it is not a js problem.

How to get text from textnodes seperated by whitespace using Selenium and Python

♀尐吖头ヾ 提交于 2021-02-05 07:44:49
问题 I am on this page: https://fantasy.premierleague.com/statistics When you click on any "i" icon next to a player, a popup window appears. Then, i want to get the surname of the player. This is how "inspect element" looks like ("whitespace" actually appears within a box): <h2 class="ElementDialog__ElementHeading-gmefnd-2 ijAScJ"> Kevin whitespace De Bruyne What i want to do is to take the text that appears after the whitespace. I can get the full text (ie both name and surname) using this: