Quantcast
Channel: Active questions tagged selenium - Stack Overflow
Viewing all 98459 articles
Browse latest View live

Extracting a date from webpage using selenium webdriver

$
0
0

For one of my projects, i am trying to run a looped script (for and while) which would run until a particular predefined date value is reached.My code is aimed at extracting the flight data of an aircraft between two specified dates. My source of information is the publicly available flight tracker, <flightradar24.com>, for which i also have a business subscription.For example - https://www.flightradar24.com/data/aircraft/d-abytWhen trying to collect a list of flights from the page, i want to be able to read a date and stop the loop if it is over the specified date.

The html source looks like the following:HTML exampleIn this case the 22 Mar 2020 is what I want to read and use to compare.

So far I've tried the following to try and extract the date.

element = driver.find_element_by_class_name('w40 hidden-xs hidden-sm')

print(driver.find_element_by_xpath("//time[@class='hidden-xs hidden-sm']").text)

print(driver.find_element_by_xpath("//time[@class='w40 hidden-xs hidden-sm']").get_attribute("data-time-format"))

and

element = driverfox.find_element_by_xpath('// time[ @class ="data-time-format"] / @ datetime'.__getattribute__("data-time-format"))

Thank you in advance for your advice !!Have a great day !


element click intercepted using Java

$
0
0

Console shows below errors :

Starting ChromeDriver 86.0.4240.22 (398b0743353ff36fb1b82468f63a3a93b4e2e89e-refs/branch-heads/4240@{#378}) on port 12848Only local connections are allowed.Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.ChromeDriver was started successfully.[1606582973.595][WARNING]: This version of ChromeDriver has not been tested with Chrome version 87.Nov 28, 2020 10:32:55 PM org.openqa.selenium.remote.ProtocolHandshake createSessionINFO: Detected dialect: W3CException in thread "main" org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element <input type="submit" value="Send" class="wpcf7-form-control wpcf7-submit button"> is not clickable at point (522, 587). Other element would receive the click: <span class="desktop-text">...</span>  (Session info: chrome=87.0.4280.66)Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'System info: host: 'PLANET', ip: '192.168.0.106', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '12.0.1'Driver info: org.openqa.selenium.chrome.ChromeDriverCapabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 87.0.4280.66, chrome: {chromedriverVersion: 86.0.4240.22 (398b0743353ff..., userDataDir: C:\Users\Admin\AppData\Loca...}, goog:chromeOptions: {debuggerAddress: localhost:56606}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:virtualAuthenticators: true}Session ID: 80bd603f6492d9dc7b4f71d2ae7d5edb    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:285)    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:84)    at MailTest.main(MailTest.java:46)

I am tried using waits and Javascript Executor but no luck for this error .Below is my code I am using :

import org.openqa.selenium.By;import org.openqa.selenium.JavascriptExecutor;import org.openqa.selenium.WebDriver;import org.openqa.selenium.WebElement;import org.openqa.selenium.chrome.ChromeDriver;import org.openqa.selenium.firefox.FirefoxDriver;import org.openqa.selenium.support.ui.ExpectedConditions;import org.openqa.selenium.support.ui.WebDriverWait;public class MailTest {    public static void main(String[] args) throws InterruptedException {        // TODO Auto-generated method stub        System.setProperty("webdriver.chrome.driver","C:/chromedriver.exe");         WebDriver driver = new ChromeDriver();        driver.get("testUrl");        //Maximizing window         driver.manage().window().maximize();         driver.findElement(By.xpath("//body/div[@id='offer--modal']/div[1]/div[2]/p[1]")).click();         Thread.sleep(10000);         WebElement Name = driver.findElement(By.xpath("//input[@id='name']"));         Name.sendKeys("test");          WebElement email = driver.findElement(By.xpath("//input[@id='email']"));         email.sendKeys("Gtest@gmail.com");         WebElement Subject = driver.findElement(By.xpath("//input[@id='subject']"));         Subject.sendKeys("Testing");         driver.findElement(By.xpath("//span[contains(text(),'Mobile Development')]")).click();         driver.findElement(By.xpath("//span[contains(text(),'Application Development')]")).click();         driver.findElement(By.xpath("//textarea[@id='message']")).sendKeys("testing for automation");     WebElement Sendbutton = driver.findElement(By.xpath("//body/div[4]/div[2]/div[1]/div[1]/div[1]/section[1]/div[1]/form[1]/div[7]/input[1]"));         JavascriptExecutor executor = (JavascriptExecutor)driver;         executor.executeScript("arguments[0].click()", Sendbutton);        // driver.close();    }}

Above script works fine till submit button I am trying to get clicked.Also , I feel that May be the problem is with the xpath of submit button. I am using chropath for finding xpaths.

Using selenium: How to keep logged in after closing Driver in Python in whatsapp

$
0
0

I don't want to log in over and over again in https://web.whatsapp.com. I've tried some solutions but it's not working using selenium chrome driver.

options=Optionsoptions.add_argument("user-data-dir=C:\\Users\\oyo\AppData\\Local\\Google\\Chrome\\User Data")browser = webdriver.Chrome("chrome_options=options")TypeError: add_argument() missing 1 required positional argument: 'argument'

Python / Selenium / Beautiful Soup not scraping desired elements

$
0
0

I'm struggling to get this code to extract the desired information from one single page.

I've tried all the usual selenium tactics and added a time delay. Hopefully, it's something simple. I'm not getting any error messages.

from selenium import webdriverfrom selenium.webdriver.chrome.options import Optionsfrom bs4 import BeautifulSoup as bsfrom time import sleepoptions = Options()options.add_argument("--headless")options.add_argument("window-size=1400,600")user_agent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 11_0_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.67 Safari/537.36"options.add_argument(f'user-agent={user_agent}')capabilities = { 'chromeOptions':  { 'useAutomationExtension': False},'args': ['--disable-extensions']}browser = webdriver.Chrome(executable_path=r'/usr/local/bin/chromedriver',desired_capabilities = capabilities,options=options)url='https://groceries.asda.com/product/celery-spring-onions/asda-growers-selection-trimmed-spring-onions/41676'browser.get(url)sleep(3)source_data = browser.page_sourcebs_data = bs(source_data,"html.parser")#product idtry:    product_id = bs_data.findfindAll('span', {'class': 'pdp-main-details__product-code'})           product_id = product_id.replace('Product code:','').strip()except:    product_id = "n/a"#image address try:    for image in bs_data.find("div", {"class":"s7staticimage"}):        image_url = image.find('img')['src']except:       image_url = "n/a"   #product descriptiontry:    product_desc = bs_data.find('class',{'pdp-main-pdp-main-details__title'})    product_desc = product_desc.get_text().strip()except:    product_desc = "n/a"#product pricetry:    product_price = bs_data.find('class',{'co-product__price pdp-main-details__price'})    product_price = product_price.get_text().strip()except:    product_price = "n/a"print (url,'|',image_url,'|',product_id,'|',product_desc,'|',product_price)        browser.quit()

Any assistance is greatly appreciated.

Thanks

RequestError: socket hang up in webdriver when used in ava

$
0
0

I use the testing framework ava in combination with Electron and Spectron on macOS to test my app.

So I setup a Gitlab pipeline which executes npm run ava after building. I noticed that occasionally some tests fail with the following error message:

test1.ts › Test Foo (23s)ℹ bla blaℹ bla blaℹ bla blatest1.ts › afterEach.always hook for Test Fooℹ bla blaℹ bla bla end of test here  Unhandled rejection in test/test1.ts  RequestError: socket hang up› ClientRequest.<anonymous> (node_modules/webdriver/node_modules/got/dist/source/core/index.js:953:111)› ClientRequest.origin.emit (node_modules/webdriver/node_modules/@szmarczak/http-timer/dist/source/index.js:39:20)

It looks like that a test is hitting a kind of 30 second timeout somewhere. I execute the jobs serially, and I set the timeout to 90 seconds in package.json:

"ava": "node_modules/.bin/ava --timeout 90s --verbose --serial --fail-fast --color true",

From ava --help:

-T, --timeout    Set global timeout (milliseconds or human-readable,                                     e.g. 10s, 2m)                                 [string]

Does anyone know what is going on here?

Powershell and selenium chromedriver getting SSL error opening website

$
0
0

I get an ssl error trying to get the chromedriver to launch. Not sure if its the options Im using or what. WebDriver 3.14
ChromeDriver downloaded from here
https://chromedriver.chromium.org/home
Using Chrome 87

Browsing to the website manually and inspecting the SSL cert, it looks fine.

Running the powershell script below, website opens, but in the terminal, I see the following ssl-related errors. Am I missing something?

ERROR:ssl_client_socket_impl.cc(960)] handshake failed; returned -1,SSL error code 1, net_error -100

Powershell code

$workingPath = 'D:\tools\Selenium'# Add the working directory to the environment path.# This is required for the ChromeDriver to work.if (($env:Path -split ';') -notcontains $workingPath) {    $env:Path += ";$workingPath"}    # Import Selenium to PowerShellImport-Module "$($workingPath)\WebDriver.dll"#-- options$ChromeOptions = New-Object OpenQA.Selenium.Chrome.ChromeOptions    $ChromeOptions.AcceptInsecureCertificates = $True  $ChromeOptions.AddArguments(@("--disable-extensions","--safebrowsing-disable-download-protection","--safebrowsing-disable-extension-blacklist","--disable-download-protection","--disable-notifications","--ignore-certificate-errors""--ignore-ssl-errors"))# Create a new ChromeDriver Object instance.$ChromeDriver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($ChromeOptions)# Launch a browser and go to URL$ChromeDriver.Navigate().GoToURL('https://weburl.here.com/')

Bet365 detects Selenium Chromedriver

$
0
0

I have a problem, that https://bet365.com started to block Selenium bots.

I've tried everything, now my code looks like:

username = os.getenv("USERNAME")userProfile = "C:\\Users\\" + username +"\\AppData\\Local\\Google\\Chrome\\User Data\\Default"opts = webdriver.ChromeOptions()opts.add_argument("user-data-dir={}".format(userProfile))opts.add_argument('--profile-directory=Profile 2')opts.add_argument("user-agent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36'")opts.add_experimental_option('useAutomationExtension', False)opts.add_experimental_option("excludeSwitches", ["enable-automation", "ignore-certificate-errors", "safebrowsing-disable-download-protection", "safebrowsing-disable-auto-update", "disable-client-side-phishing-detection"])opts.add_argument("--disable-notifications")opts.add_argument("--disable-blink-features")opts.add_argument("--disable-blink-features=AutomationControlled")opts.add_experimental_option("excludeSwitches", ["enable-automation"])opts.add_experimental_option('useAutomationExtension', False)self.browser = webdriver.Chrome(options=opts, executable_path=self.resource_path("chromedriver.exe"))window_size = self.browser.execute_script("""        return [window.outerWidth - window.innerWidth + arguments[0],          window.outerHeight - window.innerHeight + arguments[1]];""", width, height)self.browser.set_window_size(*window_size)self.browser.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {"source": """        Object.defineProperty(navigator, 'webdriver', {        get: () => undefined    })"""})self.browser.execute_cdp_cmd("Page.addScriptToEvaluateOnNewDocument", {"source": """        Object.defineProperty(navigator, 'languages', {        get: () => ["en-US", "en", "es"]    })"""})self.browser.execute_cdp_cmd("Network.enable", {})self.browser.execute_cdp_cmd("Network.setExtraHTTPHeaders", {"headers": {"User-Agent": "browser1"}})self.browser.execute_cdp_cmd('Network.setUserAgentOverride',            {"userAgent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.66 Safari/537.36'})

After launching programm browser is stuck on this: Bet365 Screenshot

And when I go to the website manually by myself, all is ok, it loads.

Can anyone help me with this problem?

OpenQA.Selenium.WebDriverException: The new session command returned a value ('Unknown error') that is not a valid JSON object

$
0
0

Introductions

I am developing an application that uses different types and versions of selenium libraries.

The goal of the application is to run Microsoft Edge and the value of the parameter associated with the EdgeDriver class is to navigate to the URL.


Problem

When running the application in the IDE (JetBrains Rider), an error occurs even though Microsoft Edge was running correctly.


Error

[19:56:40.601] - Listening on http://127.0.0.1:20082/[19:56:40.601] - Listening on http://[::1]:20082/Unhandled exception. OpenQA.Selenium.WebDriverException: The new session command returned a value ('Unknown error') that is not a valid JSON object.   at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)   at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)   at OpenQA.Selenium.Chromium.ChromiumDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)   at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeDriverService service, EdgeOptions options, TimeSpan commandTimeout)   at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeDriverService service, EdgeOptions options)   at OpenQA.Selenium.Edge.EdgeDriver..ctor(EdgeOptions options)   at OpenQA.Selenium.Edge.EdgeDriver..ctor()   at WebRequest_Login.InstagramSelenium.Main(String[] args) in C:\Users\Alexx\RiderProjects\WebRequest-Login\WebRequest-Login\Program.cs:line 191

Source Code

    EdgeDriver driver = new EdgeDriver();    driver.Navigate().GoToUrl("Instagram.com");    IWebElement usernameInput = driver.FindElement(By.CssSelector("input[name='username']"));    IWebElement passwordInput = driver.FindElement(By.CssSelector("input[name='password']"));    usernameInput.SendKeys("YourUsername");    passwordInput.SendKeys("YourPassword");

NuGet Libraries / Packages

Selenium.WebDriver.MSEdgeDriver - Version 87.0.669

Selenium.WebDriver - Version 4.0.0-alpha07


RobotFramework expected arguments

$
0
0

I am trying to run some test with Robot Framework, but when I try this code I get the following error

*** Settings ***Library    SeleniumLibrarySuite Setup     Go to homepageSuite Teardown     Close All Browsers*** Variables *** ${HOMEPAGE}          http://www.google.com${BROWSER}           chrome*** Test Cases ***Google mdh and find mdh.se           Google and check results    mdh    www.mdh.se*** Keywords ***Google and check results         [Arguments]     ${accept}    ${searchkey}   ${result}         Click Button class=RveJvd snByac   ${accept}           Click Button    name=btnK   ${searchkey}         Wait Until Page Contains    ${result}Go to homepage       Open Browser           ${HOMEPAGE}          ${BROWSER}

Keyword 'Google and check results' expected 3 arguments, got 2.

Cannot read property 'click' of undefined while using Java Script Executor in Selenium

$
0
0

I am getting an error:

Cannot read property 'click' of undefined

while trying to click a button using java script executor. I have tried many different approach to click the button using action classes, webdriverwait etc but none seems to work.Java Script is working in console but when i am using in my code i am unable to click the button and getting the mentioned error

The html dom looks as below:

<div><a class="button button--new-resource" href="/admin/certificate_types/new"><img src="/assets/icon-add-user-e2a98953aa1855b15304eb16415b536ee92e579ce89f429bcdd062faa855e261.svg" alt="Icon add user"> New Certificate Type</a></div>

My selenium script is as below

JavascriptExecutor js=(JavascriptExecutor) driver;        js.executeScript("var x= document.getElementsByClassName('button button--new-resource')[0];"+"x.click();");

How would I revise my code so that it iterates through sections of a list and handles some URL stuff in between those sections?

$
0
0

Thanks for being here! I have a block of code that scrapes/interacts with a website which looks like this:

listurl = 'https://thewebsitethatimworkingon.com/thepageitson'alert_accept()driver.get(listurl)alert_accept()############################################################################################driver.refresh()# import our list, the Select function, the By function for selections, expected conditions, and our time function so we can sleep from kiberlist import mfrnumbersfirstportion as mfrnumbersfrom selenium.webdriver.support.ui import Selectfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support import expected_conditions as ECimport time# from testnumber import testnumbers as tlnum for number in mfrnumbers:        # we find the listactions menu, and utilize the "add item" option        WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "#listActions")))        alert_accept()        print('Finding listactions...')        select_am = Select(driver.find_element_by_css_selector('#listActions'))        alert_accept()        print("Found it. Selecting...")        select_am.select_by_value('addItems')        print('Selected. Next...')        # paste our item number into the box paste it         print('Locating model number search....')        inputidbox = driver.find_element_by_id('model-number-search')        print('Located? Pasting model number...')        inputidbox.send_keys(number)          # finally add our item        additembutton = driver.find_element_by_css_selector('.gtmAddItemToList')        print('Located add item button...')        additembutton.click()           print('Item number added. Next...')        print('Locating blank space...')        WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "#addItemsToListModal > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > button:nth-child(1) > svg:nth-child(1) > path:nth-child(1)")))        time.sleep(1)        xbutton = driver.find_element_by_css_selector('#addItemsToListModal > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > button:nth-child(1) > svg:nth-child(1) > path:nth-child(1)')        xbutton.click()        time.sleep(1)

I need it to change quite a bit. That long python list of numbers I have called mylist that is being looped through is a list of product numbers I am adding to a list on the website (like Amazon for example has lists). On the website I am interacting with, you can add items to those respective lists by product number; however, each list caps out at 250 items, and I have just under 5000 to add, so I need to utilize multiple lists.

Currently, the function I've written opens the website's list url page, and then iterates through all of the product numbers in mylist and adds them to the website list. Since the website list hits its maximum at 250 items, I need to break this function up to do something like...

codestufffor items in mylist    add 250 items    click "new list" button    name the list (iteratively as we go, like list0, and then list1, list2, list3 and so on)    // (repeat until mylist has been exhausted)codestuff

I really appreciate any and all help. I am kind of stumped and unsure of where to go from here!

Open a new tab using JavascriptExecutor of selenium in Internet Explorer

$
0
0

I am using

((JavascriptExecutor) driver).executeScript("window.open();");

to open a new tab. It works fine in Chrome using selenium driver but not in IE, any suggestions? Thanks

Have tried this also: but no luck

 ((JavascriptExecutor) driver).executeScript("window.open('http://www.google.com','_blank');");

org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start with Selenium and Java

$
0
0

I have tried everything that has been told in Stackoverflow topics. I have java selenium tests run on remote slave through jenkins. The absurd thing is first test always run and browsers opens, all other tests give me "Timed out waiting for driver server to start".

public WebDriver startChrome() {    System.setProperty("java.net.preferIPv4Stack", "true");    System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");    ChromeOptions chromeOptions = new ChromeOptions();    Map<String, Object> prefs = new HashMap<String, Object>();    prefs.put("credentials_enable_service", false);    prefs.put("profile.password_manager_enabled", false);    chromeOptions.addArguments("--no-sandbox");     chromeOptions.addArguments("--disable-dev-shm-usage");     chromeOptions.addArguments("--aggressive-cache-discard");     chromeOptions.addArguments("--disable-cache");     chromeOptions.addArguments("--disable-application-cache");     chromeOptions.addArguments("--disable-offline-load-stale-cache");     chromeOptions.addArguments("--disk-cache-size=0");    chromeOptions.addArguments("--dns-prefetch-disable");     chromeOptions.addArguments("--no-proxy-server");     chromeOptions.addArguments("--log-level=3");     chromeOptions.addArguments("--silent");     chromeOptions.addArguments("--disable-browser-side-navigation");     chromeOptions.setPageLoadStrategy(PageLoadStrategy.NORMAL);     chromeOptions.addArguments("-disable-cache");    chromeOptions.addArguments("-disable-extensions");    chromeOptions.addArguments("--incognito");    chromeOptions.addArguments("start-maximized");    //chromeOptions.setExperimentalOption("useAutomationExtension", false);    ChromeDriverService chromeDriverService = ChromeDriverService.createDefaultService();    port = chromeDriverService.getUrl().getPort();    return new ChromeDriver(chromeDriverService, chromeOptions);}

Error:

Caused by: org.openqa.selenium.WebDriverException: Timed out waiting for driver server to start.Build info: version: '4.0.0-alpha-7', revision: 'de8579b6d5'System info: host: 'ISTDTSTYNMD04V', ip: '10.52.253.54', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_271'Driver info: driver.version: unknown    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:231)    at org.openqa.selenium.remote.service.DriverService.lambda$start$0(DriverService.java:193)    at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1604)    at java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1596)    at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)    at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1067)    at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1703)    at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:172)Caused by: org.openqa.selenium.net.UrlChecker$TimeoutException: Timed out waiting for [http://localhost:35592/status] to be available after 20000 ms    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:90)    at org.openqa.selenium.remote.service.DriverService.waitUntilAvailable(DriverService.java:227)    ... 7 moreCaused by: java.util.concurrent.TimeoutException    at java.util.concurrent.FutureTask.get(FutureTask.java:205)    at org.openqa.selenium.net.UrlChecker.waitUntilAvailable(UrlChecker.java:88)    ... 8 more

All the solutions I have tried so far:

  • Update Java 1_8_271
  • Update Selenium 4
  • Update ChromeDriver 87
  • Check localhost traffic with rawcap
  • Check localhost dns definiton in etc/hosts
  • Update Chrome 87
  • Set Proxy
  • Check port availability
  • Check driver path
  • Kill all chrome and driver tasks before create (Only solution that worked, but not good for parallel tests)
  • Check localhost url and port is accessible with chrome -> http 200

When I try to reach url and port through java urlconnection in code driver create function catch block), it gives me connection reset but in chrome it gives 200.

All help will be appreciated.

Best Regards

How to select item in dropdown list using Selenium?

$
0
0

Dear Stack Overflowers,

I'm making a script that automatically pays off my CC's. I'm having some trouble selecting an option in a dropdown list on the CC's webpage. The code below has every step to complete the payment except the dropdown option that tells the script to select my checking as the form of payment.

from selenium import webdriverfrom selenium.webdriver.common.keys import Keysfrom selenium.webdriver.common.by import Byfrom selenium.webdriver.support.ui import WebDriverWaitfrom selenium.webdriver.support import expected_conditions as ECimport yamlimport timeconf = yaml.load(open(r'D:\Users\Matt\Documents\GitHub\YML_Files\REI_Login_Credentials.yml'))myREIUsername = conf['REILogin']['username']myREIPassword = conf['REILogin']['password']driver = webdriver.Firefox(    executable_path=    r'D:\Users\Matt\Documents\GitHub\Executable_Files\geckodriver.exe')def login():   driver.get('https://onlinebanking.usbank.com/Auth/Login?usertype=REIMC&redirect=login&lang=en&exp=')   time.sleep(4)   driver.find_element_by_id('aw-personal-id').send_keys(myREIUsername)   driver.find_element_by_id('aw-password').send_keys(myREIPassword)   time.sleep(2)   driver.find_element_by_id('aw-log-in').click()   time.sleep(10)   make_payment()def make_payment():    if (driver.find_element_by_class_name('accountRowLast').text) != "0.00":        driver.find_element_by_css_selector('a.soloLink.accountNamesize').click()        time.sleep(3)        driver.find_element_by_xpath('/html/body/div[4]/div[2]/div[2]/div[2]/div[4]/div[3]/div[10]/div[2]/div[2]/a').click()        time.sleep(10)        driver.find_element_by_id('fromAccountDropDown-button').click()        driver.find_element_by_id('rdoAmountOptionSingleCurrent_1')        driver.find_element_by_id('btnTPContinue').click()    else:        driver.quit()login()

Here's a screenshot of what I'm trying to select and the HTML for that section.

enter image description here

I'm still learning how to use webdriverwait so I only have time.sleep() as the waiting method for now.

Any help would be appreciated!

How to extract info within a #shadow-root (open) using Selenium Python?

$
0
0

I got the next url related to an online store https://www.tiendasjumbo.co/buscar?q=mani and I can't extract the product label an another fields:

from selenium import webdriverimport timefrom random import randintdriver = webdriver.Firefox(executable_path= "C:\Program Files (x86)\geckodriver.exe")driver.implicitly_wait(10)time.sleep(4)url =  "https://www.tiendasjumbo.co/buscar?q=mani"driver.maximize_window()driver.get(url)driver.find_element_by_xpath('//h1[@class="impulse-title"]')

What am I doing wrong, I also tried to switch the iframes but there is no way to achieve my goal? any help is welcome.enter image description here


Retrieving aria-label value using Selenium's find function

$
0
0

I have the xpath of an element on a website but I'm trying to get the aria-label value of that element.

    # NO SUCCESS: print(WebDriverWait(browser, 20).until(EC.visibility_of_element_located((By.XPATH, "element_xpath_you_found"))).get_attribute("aria-label"))    # NO SUCCESS: first_rev = browser.find_element(By.xpath, "/html/body/span/g-lightbox/div[2]/div[3]/span/div/div/div/div[2]/div[1]/div/div[2]/div[1]/div[1]/div[3]/div[1]/g-review-stars/span")    first_rev = browser.find_element_by_xpath("/html/body/span/g-lightbox/div[2]/div[3]/span/div/div/div/div[2]/div[1]/div/div[2]/div[1]/div[1]/div[3]/div[1]/g-review-stars/span").click()    aria_label = first_rev.find_element_by_css_selector('span').get_attribute("aria-label")    print(aria_label)

On the browser, I inspect the element and get this html:

<span class="fTKmHE99XE4__star fTKmHE99XE4__star-s" aria-label="Rated 3.0 out of 5," style=""><span style="width:42px"></span></span>

However, can the problem be that this element is inside a pop-up on the page? Page source doesn't show any html for any element in the pop-up.

Webscraping with Selenium and Python

$
0
0

I'm beginner in coding and try to learn webscraping with selenium, I been working on a project to check with a dictionary how long it takes to crack a password with every single word.So my code reads a .txt file that has a word on each line, then writes it to the bar and it would copy how long it would take to crack it.The problem is that I cannot capture a part of the html code of the webpage and I need help.

This is my code

# This program run spanish dictionary and check how secure password there areimport randomimport timefrom selenium import webdriver#Paste here Chromedriver pathCHROMEDRIVERPATH = "C:\Program Files (x86)\chromedriver.exe"#Paste here dictionary path in .txt formatdictionary = readFile("spanish_dictionary.txt")date = str(time.strftime("%Y-%m-%dT%H-%M-%S"))#read filesdriver = webdriver.Chrome(CHROMEDRIVERPATH)#webpage targetdriver.get("https://www.security.org/how-secure-is-my-password/")time.sleep(2)#LabelwriteFile("results_" + date +".txt","word,time \n")#File Contentfor word in dictionary:    bar = driver.find_element_by_id('password')    bar.send_keys(word)    bar.clear()    timeToCrack = driver.find_element_by_xpath('//*[@id="hsimp"]/div[1]/div[3]/p[2]').get_attribute("class")    result = word +"," + timeToCrack +"\n"    writeFile("results_" + date +".txt",result)    time.sleep(random.uniform(0.4,1.0))

This is html code of the page

<p class="result__text result__time">2 hundred microseconds</p>

I get this in output file:

word,time a,result__text result__timeaba,result__text result__timeabaá,result__text result__time

I want this:

word,time a,6 hundred picosecondsaba,4 hundred nanosecondsabaá,5 milliseconds

How to return value from JavaScript using Selenium?

Chromedriver timing out, was working before

$
0
0

I am working with Selenium/python combo and I have a bunch of scripts which were working perfectly. I then stopped using them for a month and now I get time out errors. I have tried a couple of solutions posted on-line but nothing seems to work.

This is the set-up:

selenium     3.141.0chrome       86.0.4240.75chromedriver 86.0.4240.22

and the errors I get are:

[11-28-2020 23:33:28.070][INFO]: Launching chrome: "C:\Program Files\Google\Chrome\Application\googlechrome.exe" --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging --log-level=0 --no-first-run --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Users\VB\AppData\Local\Temp\scoped_dir29140_1635643004" data:,[11-28-2020 23:33:28.589][INFO]: resolved localhost to ["::1","127.0.0.1"][11-28-2020 23:33:32.588][WARNING]: Timed out connecting to Chrome, retrying...[11-28-2020 23:33:32.588][INFO]: resolved localhost to ["::1","127.0.0.1"][11-28-2020 23:33:40.598][WARNING]: Timed out connecting to Chrome, retrying...[11-28-2020 23:33:40.598][INFO]: resolved localhost to ["::1","127.0.0.1"][11-28-2020 23:33:56.604][WARNING]: Timed out connecting to Chrome, giving up.[11-28-2020 23:33:56.606][INFO]: resolved localhost to ["::1","127.0.0.1"][11-28-2020 23:34:00.615][WARNING]: Timed out connecting to Chrome, retrying...[11-28-2020 23:34:00.615][INFO]: resolved localhost to ["::1","127.0.0.1"][11-28-2020 23:34:08.627][WARNING]: Timed out connecting to Chrome, retrying...[11-28-2020 23:34:08.627][INFO]: resolved localhost to ["::1","127.0.0.1"][11-28-2020 23:34:24.634][WARNING]: Timed out connecting to Chrome, giving up.[11-28-2020 23:34:24.659][INFO]: [fcdf702ffc801fde76b9fd0d0815b3df] RESPONSE InitSession ERROR session not createdfrom disconnected: unable to connect to renderer  (Session info: chrome=86.0.4240.75)

This is my chrome/chromedriver config:

options = Options()options.binary_location = 'C:\Program Files\Google\Chrome\Application\googlechrome.exe'chrome_driver_binary = "C:\Program Files\Chromedriver\chromedriver.exe"driver = webdriver.Chrome(chrome_driver_binary, options=options, service_args=["--disable-gpu","--readable-timestamp","--log-path=C://DOCS//python//" + className +"_" + memberName +"_TEST_chromedriver.log"])

and I changed hosts to add:

127.0.0.1       localhost

I tried upgrading chrome and chromedriver to v87 but that gave same error so I reverted to 86. As I said it was working fine before. I can't think of anything that has changed particularly.

Any ideas of what to try would be great.

Error while running pom.xml in Selenium project

$
0
0

Am getting the below error while running pom.xml file in selenium project. if i execute testng.xml it works fine.

  1. ------------------------------------------------------------------------ [INFO] BUILD FAILURE [INFO]------------------------------------------------------------------------ [INFO] Total time: 11.541 s [INFO] Finished at:2020-11-27T18:40:42-05:00 [INFO]

[ERROR] Failed to execute goalorg.apache.maven.plugins:maven-surefire-plugin:2.19.1:test(default-test) on project artfact_id: Execution default-test of goalorg.apache.maven.plugins:maven-surefire-plugin:2.19.1:test failed:There was an error in the forked process [ERROR]org.testng.TestNGException:java.security.cert.CertificateNotYetValidException: NotBefore: FriNov 27 19:16:37 EST 2020 [ERROR] atorg.testng.TestNG.initializeSuitesAndJarFile(TestNG.java:324)

[ERROR]     at org.testng.TestNG.run(TestNG.java:1101) [ERROR]  atorg.apache.maven.surefire.testng.TestNGExecutor.run(TestNGExecutor.java:281)[ERROR]     atorg.apache.maven.surefire.testng.TestNGXmlTestSuite.execute(TestNGXmlTestSuite.java:75)[ERROR]     atorg.apache.maven.surefire.testng.TestNGProvider.invoke(TestNGProvider.java:121)[ERROR]     atorg.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)[ERROR]     atorg.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)[ERROR]     atorg.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)[ERROR] Caused by:java.security.cert.CertificateNotYetValidException: NotBefore: FriNov 27 19:16:37 EST 2020 [ERROR]    atsun.security.x509.CertificateValidity.valid(CertificateValidity.java:270)[ERROR]     atsun.security.x509.X509CertImpl.checkValidity(X509CertImpl.java:629)[ERROR]     atsun.security.provider.certpath.BasicChecker.verifyValidity(BasicChecker.java:190)[ERROR]     atsun.security.provider.certpath.BasicChecker.check(BasicChecker.java:144)[ERROR]     atsun.security.provider.certpath.PKIXMasterCertPathValidator.validate(PKIXMasterCertPathValidator.java:125)[ERROR]     atsun.security.provider.certpath.PKIXCertPathValidator.validate(PKIXCertPathValidator.java:233)[ERROR]     atsun.security.provider.certpath.PKIXCertPathValidator.validate(PKIXCertPathValidator.java:141)[ERROR]     atsun.security.provider.certpath.PKIXCertPathValidator.engineValidate(PKIXCertPathValidator.java:80)[ERROR]     atjava.security.cert.CertPathValidator.validate(CertPathValidator.java:292)[ERROR]     atsun.security.validator.PKIXValidator.doValidate(PKIXValidator.java:357)[ERROR]     atsun.security.validator.PKIXValidator.engineValidate(PKIXValidator.java:270)[ERROR]     atsun.security.validator.Validator.validate(Validator.java:262)[ERROR]     atsun.security.ssl.X509TrustManagerImpl.validate(X509TrustManagerImpl.java:330)[ERROR]     atsun.security.ssl.X509TrustManagerImpl.checkTrusted(X509TrustManagerImpl.java:237)[ERROR]     atsun.security.ssl.X509TrustManagerImpl.checkServerTrusted(X509TrustManagerImpl.java:132)[ERROR]     at sun.security.ssl.ClientHandshaker.serverCertificate(Cl
Viewing all 98459 articles
Browse latest View live


Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>