selenium

Website denies get request using Selenium

假装没事ソ 提交于 2021-02-11 14:24:07
问题 I am trying to use selenium in order to automate for login into a website https://afghanbids.com/ but when I run my python program, the browser loads a page which says access denied. You may please see the screen shot below. My code: driver = webdriver.Chrome(executable_path="chromedriver.exe") driver.get("https://afghanbids.com/") It shows that: How can I make the request so that the target website does not deny my request? 回答1: I took your code, added a few tweaks and encountered the access

Selenium webdriver :org.openqa.selenium.InvalidElementStateException: Element is disabled and so may not be used for actions

巧了我就是萌 提交于 2021-02-11 14:21:51
问题 I am getting this error while trying to write to simple code in selenium webdriver to enter a value in google search page and enter. Following is my code -: WebDriver driver = new FirefoxDriver(profile); driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS); driver.get("http://www.google.com"); WebElement element=driver.findElement(By.xpath("//input[@id='gs_htif0']")); boolean b = element.isEnabled(); if (b){ System.out.println("Enabled"); } element.sendKeys("Test Automation");

How to scrape views from Youtube pages

拥有回忆 提交于 2021-02-11 14:21:22
问题 My code is good for the most part I currently get all the titles from a youtube page + do a scroll. How would I get the number of views? Would CSS or xPath work? import time from selenium import webdriver from bs4 import BeautifulSoup import requests from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from webdriver_manager.chrome import ChromeDriverManager options = Options() driver =

How can I identify the element containing the link to my linkedin profile after I logged in using selenium.webdriver?

廉价感情. 提交于 2021-02-11 14:19:35
问题 I have written a script (python) to login to my LinkedIn page (feed) and then I want the script to take me to my profile page. But I cannot capture the element with the link (it keeps changing its id with every restart of the browser). Obviously, I know the link but I would like for the script to be able to capture it. This is the code I have so far: import parameters from time import sleep from selenium import webdriver driver = webdriver.Chrome('/Users/uglyr/chromedriver') driver.get('https

Selenium EventFiringWebDriver JavaScript: SyntaxError: missing ) after argument list

馋奶兔 提交于 2021-02-11 14:18:36
问题 Trying to execute a javaScript command using the built in Selenium EventFiringWebDriver class. EventFiringWebDriver eventFiringWebDriver = new EventFiringWebDriver(driver); eventFiringWebDriver.executeScript("document.querySelector('[ng-reflect-title='Assessment']>div.cc-tile>div.cc-tile-body').scrollTop=370"); But this yields the error: Runtime.evaluate threw exception: SyntaxError: missing ) after argument list if I use a the long ccs selector that Chrome gives me for this object of: body >

How to run a single test case (method) instead of whole test suite (class) using Selenium/TestNG/Maven

元气小坏坏 提交于 2021-02-11 14:12:01
问题 So basically I am wondering how could I run a specific test case (a method) instead of running a whole class. I am running tests using a combination of Selenium/Maven/TestNG. My current testing setup looks something like this: simplified command to run tests: mvn test -DtestSuiteName="test" contents of test.xml used in the command above: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite name="Selenium Testng Template"> <test name=

How to run a single test case (method) instead of whole test suite (class) using Selenium/TestNG/Maven

懵懂的女人 提交于 2021-02-11 14:11:45
问题 So basically I am wondering how could I run a specific test case (a method) instead of running a whole class. I am running tests using a combination of Selenium/Maven/TestNG. My current testing setup looks something like this: simplified command to run tests: mvn test -DtestSuiteName="test" contents of test.xml used in the command above: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd"> <suite name="Selenium Testng Template"> <test name=

Firefox(headless)+selenium cannot access internet from docker container

泄露秘密 提交于 2021-02-11 14:02:30
问题 I have tested the internet connection by wget https://www.google.com and it worked from inside the docker. But, when I run a headless firefox with selenium python binding, selenium throughs the TimeoutException : >> docker run myselcontainer Traceback (most recent call last): File "run.py", line 24, in <module> driver = webdriver.Firefox(service_log_path=os.devnull, options=options, capabilities=capabilities, firefox_profile=profile) File "/usr/local/lib/python3.8/site-packages/selenium

Scraping multiple select options using Selenium

巧了我就是萌 提交于 2021-02-11 14:02:29
问题 I am required to scrape PDF's from the website https://secc.gov.in/lgdStateList . There are 3 drop-down menus for a state, a district and a block. There are several states, under each state we have districts and under each district there are blocks. I tried to implement the following code. I was able to select the state, but there seems to be some error when I select the district. from selenium import webdriver from selenium.webdriver.support.ui import Select import requests from bs4 import

From Selenium To Requests

北城余情 提交于 2021-02-11 13:55:53
问题 I am trying to learn how to use the requests module so i dont need to be scraping with Selenium. This is the code i have so far, that prints a table from a webpage. I cant figure out how i could use requests to make this code faster and in a pythonic way. #my imports import pandas as pd from selenium import webdriver from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium