selenium-webdriver

Selenium findElements() returns the same instance of the first element multiple times

ぃ、小莉子 提交于 2021-01-29 12:50:30
问题 I need to get the list of all article titles. But for some reason Selenium returns the same instance of the article WebElement 3 times. The web page HTML looks like this: <div id="content" class="site-content clearfix"> <div class="container clearfix"> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <article id="post-403"> <h2 class="entry-title"> <i class="trusted-entry-icon"/> <a href="https://www.example.com/title-of-article-1/" rel="bookmark">Title

NoSuchElementException (SyntaxError: too many statically nested blocks)

痴心易碎 提交于 2021-01-29 12:43:17
问题 I am new in this and I am trying to figure out if there is a better way. Scraping some data from similar pages, but elements are changing and my solution is: try: p3 = driver.find_element_by_xpath("(//div/table)[2]/tbody/tr[contains(.,'4 - 10:00')]").text except NoSuchElementException: try: p3 = driver.find_element_by_xpath("(//div/table)[2]/tbody/tr[contains(.,'3 - 00:00')]").text except NoSuchElementException: try: p3 = driver.find_element_by_xpath("(//div/table)[2]/tbody/tr[contains(.,'4 -

What is the return type of executeScript() method of JavascriptExecutor?

空扰寡人 提交于 2021-01-29 12:06:49
问题 If a JavaScript on a web page return non-decimal value then what will javascriptExecuter.executeScript() will return? Ccan anyone answer this question? 回答1: executeScript() executeScript() executes a JavaScript in the context of the currently selected frame or window. The script fragment provided will be executed as the body of an anonymous function. If the script has a return value (i.e. if the script contains a return statement), then the following type of objects are returned: For an HTML

Selenium findElements() returns the same instance of the first element multiple times

我怕爱的太早我们不能终老 提交于 2021-01-29 11:40:30
问题 I need to get the list of all article titles. But for some reason Selenium returns the same instance of the article WebElement 3 times. The web page HTML looks like this: <div id="content" class="site-content clearfix"> <div class="container clearfix"> <div id="primary" class="content-area"> <main id="main" class="site-main" role="main"> <article id="post-403"> <h2 class="entry-title"> <i class="trusted-entry-icon"/> <a href="https://www.example.com/title-of-article-1/" rel="bookmark">Title

Enabling HTTP Proxy with Auth Using Selenium and PHP WebDriver

风流意气都作罢 提交于 2021-01-29 11:08:44
问题 I am currently using Google Chrome 86.0.4240.75 with the relevant WebDriver for Selenium. I am trying to get it to work with an HTTP proxy with authorization, using the workaround provided here: https://github.com/RobinDev/Selenium-Chrome-HTTP-Private-Proxy This is my code for setting up the proxy: $this->options = new Chrome\ChromeOptions(); $zip = new \ZipArchive; $pluginForProxyLogin = __DIR__.'/../collectors/sel'.$instanceId.'.zip'; if (file_exists($pluginForProxyLogin)) unlink(

Selenium proxy server argument - unknown error: net::ERR_TUNNEL_CONNECTION_FAILED

柔情痞子 提交于 2021-01-29 11:02:16
问题 Hope you're well. I am facing a little problem when trying to set-up my chrome webdriver. I am trying to change the parameters of the webdriver to rotate the User Agent & the IP (I use it for scrapping purpose & don't want to get spot with the same IP & UA). When I pass the UA argument, everything works well. But when I add the IP argument, it systematically fails for some reasons that I can't identify. I always receive the following error WebDriverException: unknown error: net::ERR_TUNNEL

how to select a value from dynamic searchbox in selenium webdriver java?

心已入冬 提交于 2021-01-29 10:18:56
问题 enter image description here I have to select a name from this searchbox based on my input value. How I can achieve this. 回答1: Option 1: If html tag for Account name is <select>...</select> , you can use org.openqa.selenium.support.ui.Select See https://www.guru99.com/select-option-dropdown-selenium-webdriver.html Option 2: Use relationship parrent-child of elements. See Selenium Java : Dropdown items are updated dynamically and https://www.tutorialspoint.com/locating-child-nodes-of

Selenium WebDriver - Unable to drag and drop element in IE11

≡放荡痞女 提交于 2021-01-29 09:55:51
问题 I am trying to drag and drop an element from side panel to form. Drag and drop code what I wrote is like below. Actions builder = new Actions(driver); builder.dragAndDrop(source, target).build().perform(); This works fine in all browser except IE11. I tried other approaches like Approach 1 - builder.clickAndHold(source) .moveToElement(target) .release(target) .build() .perform(); Approach 2 - builder.clickAndHold(source) .pause(Duration.ofSeconds(1)) .moveByOffset(-1, -1) .pause(Duration

How to Mouse Hover over different images with dynamic xpaths through Selenium Java

隐身守侯 提交于 2021-01-29 09:51:07
问题 There are seven images. I want to do mouse hover on every image and and check AddToCart button is displayed or not. I have tried following code and it is not working. Reference: http://automationpractice.com/index.php public boolean checkMouseHoveronAllItems(WebDriver driver) { String xpathOfItems="//[@id='homefeatured']/li['+index+']/div/div[1]/div/a[1]/img"; String xpathOfAddToCartButtons="//div[@class='button-container']/a[@title='Add to cart']"; boolean res=false; for(int index=1;index<

Issues adding WebDriverWait in a for loop - selenium

无人久伴 提交于 2021-01-29 09:45:13
问题 I have the following code, which runs well: titles = results.find_elements_by_class_name("docsum-title") for title in titles: print(title.text) It prints out a list of titles from the find_elements_by_class_name . The title's are also hrefs which I want to click to. However, once I add click functions on title.text hyperlinks that go to a new page, (code below) titles = results.find_elements_by_class_name("docsum-title") for title in titles: print(title.text) title_wait = WebDriverWait(driver