selenium

Selenium Python - Explicit waits not working

*爱你&永不变心* 提交于 2021-01-27 19:04:36
问题 I am unable to get explicit waits to work while waiting for the page to render the js, so I am forced to use time.sleep() in order for the code to work as intended. I read the docs and still wasn't able to get it to work. http://selenium-python.readthedocs.io/waits.html The commented out section of code with the time.sleep() works as intended. The WebDriverWait part runs but does not wait. from selenium import webdriver import time from selenium.webdriver.support.ui import WebDriverWait from

Selenium: access denied

眉间皱痕 提交于 2021-01-27 19:00:31
问题 I am trying to scrape some data from LV website with Selenium and keep getting 'Access Denied' screen once 'sign in' button clicked. I feel like there is a protection against this because all seems to be working fine when I do the same manually. Oddly, I need to click 'sign in' button twice to be able to sign in manually. My code: from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver

SyntaxError: invalid syntax while using find_element_by_xpath using Selenium in Python

余生颓废 提交于 2021-01-27 18:53:27
问题 Code Trials: from selenium import webdriver driver = webdriver.Firefox() driver.get("http://www.niftyindices.com/reports/historical-data") driver.maximize_window() driver.find_element_by_xpath("//*[@id="ddlHistorical"]").send_keys("NIFTY 100") I am getting an error: File "<ipython-input-32-592f058980cd>", line 5 driver.find_element_by_xpath("//*[@id="ddlHistorical"]").send_keys("NIFTY 100") ^ SyntaxError: invalid syntax 回答1: This error message... SyntaxError: invalid syntax ...implies that

Chrome Browser Headless problem : Some specific pages are not rendering in Headless mode

偶尔善良 提交于 2021-01-27 18:30:38
问题 I am trying to automate a process using selenium and chrome browser in Python. My browser works correctly for most pages but is unable to render a few pages including chrome://version/ . For general automation(without headless) it returns the page and page source correctly, whereas for headless browsing it returns a blank page with page source as below <html><head></head><body></body></html> I have tried chrome in the different operating system including OpenSUSE, fedora, and Windows. I have

Selenium: Click on a “<div><a></a></div>” button

空扰寡人 提交于 2021-01-27 18:18:33
问题 I tried to click on a button. It has this structure: <div class="button-wrapper" id="button-verify-wrapper"> <a x-ng-click="verifySfdcConnection()" class="clearfix float-left button-green"> <div class="icon-green icon-green-verify"></div> <div class="button-label ng-binding">Verify Connection</div> </a> <div x-ng-class="{'connection-verified':wizardData.inputSource.sfdc.connectionStatus}" x-ng-show="wizardData.inputSource.sfdc.connectionStatus" style="" class="connection-verified"></div> <

How to pass validated user input with in an input field of a webpage using Selenium and Python

北慕城南 提交于 2021-01-27 18:12:02
问题 I want the user to type in her/his name then pass the user input to selenium so that it automatically types it in the search field for my website. Is possible to first input, press enter then trigger selenium to forward the input to the browser. Why is it not working? from selenium import webdriver import time browser = webdriver.Chrome('C:/Users/acer/Desktop/chromedriver') browser.get('website') x = str(input('Your name: ')) #user inputs name here if len(x) > 20: #the name van not be longer

Selenium Chrome & Firefox WebDriver: Set HTTPS proxy in Python

↘锁芯ラ 提交于 2021-01-27 18:06:01
问题 I've done plenty of searching however there is a lot of confusing snippets out there that are very similar. I've attempted to use the DesiredCapabilities , ChromeOptions , Options and a series of arguments but nothing is working :( It fails to set a proxy. For example ( ChromeOptions ) chrome_options = webdriver.ChromeOptions() chrome_options.add_argument('--proxy=https://' + proxy_ip_and_port) chrome_options.add_argument('--proxy-auth=' + proxy_user_and_pass) chrome_options.add_argument('-

How to pass validated user input with in an input field of a webpage using Selenium and Python

女生的网名这么多〃 提交于 2021-01-27 18:05:05
问题 I want the user to type in her/his name then pass the user input to selenium so that it automatically types it in the search field for my website. Is possible to first input, press enter then trigger selenium to forward the input to the browser. Why is it not working? from selenium import webdriver import time browser = webdriver.Chrome('C:/Users/acer/Desktop/chromedriver') browser.get('website') x = str(input('Your name: ')) #user inputs name here if len(x) > 20: #the name van not be longer

How to verify dimensions of image in Selenium Java Webdriver?

一曲冷凌霜 提交于 2021-01-27 17:45:58
问题 I want to verify the first image on my page is a certain dimension. I have the code I'm using right now to GET the dimensions, but now, I need to verify that the image is 1024 pixels wide... How do I do this? Dimension elementDimensions=(Insert Element Here).get(0).getSize(); elementDimensions.getHeight(); elementDimensions.getWidth(); Assert.assertTrue......... 回答1: I think you already getting width and height from driver and known what would be the expected value. So you can use Assertions

Selenium: Can't locate element

China☆狼群 提交于 2021-01-27 17:25:36
问题 I am trying to switch to frame but Selenium can't locate the element. Here is HTML code which I get with Selenium before locating: <div class="jqmPopOverlay" style="height: 100%; width: 100%; position: fixed; left: 0px; top: 0px; z-index: 2999; opacity: 0.7;"></div><div class="login login-main jqmID1" id="loginForm" style="z-index: 3000; top: 0px; left: 319.5px; display: block;"> <div class="titlebar"> <a class="close" href="#" tabindex="7">✕</a> </div> <div class="tooltipstered" id=