我想废弃 immowelt.de,但我无法通过 cookie 横幅。我尝试使用 sleep() 和 WebDriverWait 等待横幅加载,但是它们都不起作用。
这是网络驱动程序的代码
from selenium import webdriver
from selenium.webdriver.common.by import By
import time
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
chrome_driver_path = '.../chromedriver'
url = 'https://www.immowelt.de/immobilienpreise'
driver = webdriver.Chrome(executable_path=chrome_driver_path)
driver.get(url)
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="uc-center-container"]/div[2]/div/div/div/div[1]/button'))).click()
driver.close()
Run Code Online (Sandbox Code Playgroud)
这是带有睡眠的代码
from selenium import webdriver
import time
from selenium.webdriver.common.by import By
chrome_driver_path = '.../chromedriver'
url = 'https://www.immowelt.de/immobilienpreise'
driver = webdriver.Chrome(executable_path=chrome_driver_path)
driver.get(url)
time.sleep(5)
driver.find_element(By.XPATH, '//*[@id="uc-center-container"]/div[2]/div/div/div/div[1]/button').click()
driver.close()
Run Code Online (Sandbox Code Playgroud) cookies selenium selenium-webdriver shadow-dom queryselector
由于某种原因,在添加一系列 WebDriver 选项后,我的 Python 代码显示为无法访问。有谁知道为什么会发生这种情况以及如何解决它?

代码本身如下:
class DriverOptions(object):
def __init__(self):
self.options = Options()
self.options.add_argument('--no-sandbox')
self.options.add_argument('--start-maximized')
self.options.add_argument('--start-fullscreen')
self.options.add_argument('--single-process')
self.options.add_argument('--disable-dev-shm-usage')
self.options.add_argument("--incognito")
self.options.add_argument('--disable-blink-features=AutomationControlled')
self.options.add_argument('--disable-blink-features=AutomationControlled')
self.options.add_experimental_option('useAutomationExtension', False)
self.options.add_experimental_option("excludeSwitches", ["enable-automation"])
self.options.add_argument("disable-infobars")
self.helperSpoofer = Spoofer()
self.options.add_argument('user-agent={}'.format(self.helperSpoofer.userAgent))
self.options.add_argument('--proxy-server=%s' % self.helperSpoofer.ip)
Run Code Online (Sandbox Code Playgroud) selenium web-crawler python-3.x selenium-chromedriver chrome-options
如果我们创建:
ChromeDriver driver=new ChromeDriver();
Run Code Online (Sandbox Code Playgroud)
chrome 驱动程序方法将被执行。
如果我们创建:
WebDriver driver=new ChromeDriver();
Run Code Online (Sandbox Code Playgroud)
再次ChromeDriver执行方法[根据方法覆盖]。
那为什么我们只在执行时写后一个呢?
java selenium webdriver selenium-webdriver webdriver-w3c-spec
当我尝试在java中使用selenium webdriver运行我的第一个测试用例时,我得到以下异常.有人可以帮我解决问题.....
Starting ChromeDriver 2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f) on port 48523
Only local connections are allowed.
log4j:WARN No appenders could be found for logger (org.apache.http.client.protocol.RequestAddCookies).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Mar 29, 2018 7:34:16 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: call function result missing 'value'
(Session info: chrome=65.0.3325.181)
(Driver info: chromedriver=2.33.506120 (e3e53437346286c0bc2d2dc9aa4915ba81d9023f),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration …Run Code Online (Sandbox Code Playgroud) java selenium webdriver selenium-chromedriver selenium-webdriver
我有以下代码:
options = Options()
options = options.set_headless( headless=True)
class Sel_Driver():
def __init__(self):
self.driver = webdriver.Firefox(firefox_options=options)
Run Code Online (Sandbox Code Playgroud)
然后,我可以将其self.driver.get(url)用作方法的一部分来打开我输入的 URL。这有效 - 我可以输入并打开 URL,但它们不在无头模式下。
(我最初将驱动程序定义为self.driver = webdriver.Firefox(firefox_options=Options().set_headless(headless=True)- 但这不起作用,所以我如上所述尝试了它)。
我错过了什么?我不明白为什么驱动程序能够打开页面,但选项未启用。
我一直在使用UiPath Studio来自动化工作流程,并取得了成功。现在,我想创建一个仅在我的本地主机上部署的UiPath Robot。
我已经观看了一些视频,例如UiPath入门教程-将机器人部署到Orchestrator || 安排一个机器人Uipath,它似乎需要UiPath Orchestrator的帮助。
我的问题是:
我想提取我尝试过的所有<li>元素文本<ul>
elem = driver.find_elements_by_xpath(("//div[@class='left width50']/p/b/ul"))
len(elem)
Run Code Online (Sandbox Code Playgroud)
给出 '0' 或空列表。
这是 html 源代码
<div class="left width50">
<p><b>Features:</b></p>
<ul>
<li>Easy spray application</li>
<li>Excellent bonding properties</li>
<li>Single package</li>
<li>Mixed with clean potable water at job site</li>
</ul>
</div>
Run Code Online (Sandbox Code Playgroud)
这里是网站的链接
有什么建议怎么办?
ErrorOccuredDuringInitializationofbootlayer我在运行测试时不断收到此错误:
启动层初始化时出错 java.lang.module.FindException:无法为 C:\Users\Bonfire.eclipse\org.eclipse.platform_4.12.0_867647348_win32_win32_x86_64\plugins\com.beust.jcommander_1.72.0.jar 派生模块描述符引起:java.lang.IllegalArgumentException:com.beust.jcommander.1.72.0:无效的模块名称:'1'不是Java标识符
我该如何解决?
我看到了类似的问题,但就我而言,我的代码中甚至没有“init”函数。如何解决这个问题呢?问题出在线路上(EC.element_to_bo_clickable)
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome(executable_path="C:\Chromedriver\chromedriver.exe")
driver.implicitly_wait(1)
driver.get("https://cct-103.firebaseapp.com/")
element = WebDriverWait(driver, 1).until
(EC.element_to_be_clickable(By.CLASS_NAME, "MuiButton-label"))
element.click()
Run Code Online (Sandbox Code Playgroud) import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.support.ui.ExpectedConditions;
import org.openqa.selenium.support.ui.WebDriverWait;
public class NewGmail {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
String url = "https://accounts.google.com/signin";
driver.get(url);
driver.findElement(By.id("identifierId")).sendKeys("cp8805");
//driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
WebDriverWait wait=new WebDriverWait(driver, 20);
driver.findElement(By.xpath("//span[@class='RveJvd snByac']")).click();
driver.manage().timeouts().implicitlyWait(40, TimeUnit.SECONDS);
driver.findElement(By.xpath("//input[@class='whsOnd zHQkBf']")).sendKeys("xxxxxx");
driver.findElement(By.xpath("//span[@class='RveJvd snByac']")).click();
}
}
Run Code Online (Sandbox Code Playgroud)
在邮件ID之后我的密码也写在id框选项中,服务器重定向到下一个密码页面.我想问一下我将做什么,以便我的密码只能输入密码页面.
selenium ×9
java ×3
python ×3
webdriver ×3
firefox ×2
geckodriver ×2
cookies ×1
eclipse ×1
java-12 ×1
options ×1
python-3.x ×1
shadow-dom ×1
testng ×1
uipath ×1
uipath-robot ×1
web-crawler ×1
xpath ×1