下面是我的代码,在我将Selenium Webdriver版本更新为3.11.0之后,该代码显示为已弃用.
private Wait<WebDriver> mFluentWait(WebDriver pDriver) {
Wait<WebDriver> gWait = new FluentWait<WebDriver>(pDriver).withTimeout(100, TimeUnit.SECONDS)
.pollingEvery(600, TimeUnit.MILLISECONDS).ignoring(NoSuchElementException.class);
return gWait;
}
Run Code Online (Sandbox Code Playgroud)
在代码中显示已弃用的警告withTimeout和pollingEvery部分.
如何重写此代码以便我可以删除已弃用的警告.
由于我是硒的新手,我不确定这种变化.任何帮助将不胜感激.
driver=new ChromeDriver();它给了我错误,我用 sysout 检查,错误在 2 中,好吧,我使用 Maven 的经验不是很好,但我正在检查我的pom.xml文件,我给出了 Selenium 依赖项。- 有什么建议吗?有任何帮助表示赞赏
\n\npublic WebDriver initilizeDriver() throws IOException\n{\n Properties prop= new Properties();\n FileInputStream f\xc4\xb1s=new FileInputStream("C:\\\\Users\\\\Melih Sancak\\\\my-amazonTest\\\\src\\\\main\\\\java\\\\com\\\\ObjectRepisotary\\\\app\\\\data.properties");\n prop.load(f\xc4\xb1s);\n String browserName =prop.getProperty("browser");\n System.out.println(browserName);\n if(browserName.equals("chrome"))\n {\n System.setProperty("webdriver.chrome.driver", "C:\\\\Users\\\\Melih Sancak\\\\Downloads\\\\chromedriver.exe");\n driver=new ChromeDriver();\n }\n}\nRun Code Online (Sandbox Code Playgroud)\n\n2.错误:
\n\njava.lang.NoClassDefFoundError: com/google/common/collect/ImmutableMap\n at org.openqa.selenium.remote.service.DriverService$Builder.<init>(DriverService.java:253)\n at org.openqa.selenium.chrome.ChromeDriverService$Builder.<init>(ChromeDriverService.java:94)\n at org.openqa.selenium.chrome.ChromeDriverService.createDefaultService(ChromeDriverService.java:88)\n at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123)\nRun Code Online (Sandbox Code Playgroud)\n java selenium maven selenium-chromedriver selenium-webdriver
我正在尝试使用我现有的帐户和配置文件中的设置使用selenium加载chrome浏览器。
我可以使用ChromeOptions设置userdatadir和配置文件目录来使其工作。这会像我想要的那样用我的个人资料加载浏览器,但是浏览器随后挂起60秒钟并超时,而没有进行任何自动化操作。
如果我不使用用户数据目录和配置文件设置,则可以正常使用,但不使用我的配置文件。
我所做的阅读指出,一次不能使用相同的配置文件打开一个以上的浏览器,因此我确保在运行程序时没有打开任何文件。即使没有打开其他浏览器,它仍然挂起60秒。
m_Options = new ChromeOptions();
m_Options.AddArgument("--user-data-dir=C:/Users/Me/AppData/Local/Google/Chrome/User Data");
m_Options.AddArgument("--profile-directory=Default");
m_Options.AddArgument("--disable-extensions");
m_Driver = new ChromeDriver(@"pathtoexe", m_Options);
m_Driver.Navigate().GoToUrl("somesite");
Run Code Online (Sandbox Code Playgroud)
它始终挂在GoToUrl上。我不确定还有什么尝试。
c# selenium google-chrome selenium-chromedriver selenium-webdriver
我试图在Kubuntu 14.04上运行python中的selenium.我尝试使用chromedriver或geckodriver时出现此错误消息,两者都是相同的错误.
Traceback (most recent call last):
File "vse.py", line 15, in <module>
driver = webdriver.Chrome(chrome_options=options, executable_path=r'/root/Desktop/chromedriver')
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/chrome/webdriver.py", line 75, in __init__
desired_capabilities=desired_capabilities)
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/webdriver.py", line 156, in __init__
self.start_session(capabilities, browser_profile)
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/webdriver.py", line 251, in start_session
response = self.execute(Command.NEW_SESSION, parameters)
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/webdriver.py", line 318, in execute
response = self.command_executor.execute(driver_command, params)
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/remote_connection.py", line 375, in execute
return self._request(command_info[0], url, body=data)
File "/usr/local/lib/python3.4/dist-packages/selenium/webdriver/remote/remote_connection.py", line 397, in _request
resp = self._conn.request(method, url, body=body, headers=headers)
File "/usr/lib/python3/dist-packages/urllib3/request.py", line 79, in request …Run Code Online (Sandbox Code Playgroud) 我是自动化工程师,我已经使用 maven 在 Jenkins 上部署了我的构建,我想在执行脚本时打开浏览器。当我尝试通过命令提示符运行 Jenkins 时,我搜索了一些人说我通过 cmd 提示符运行 Jenkins 战争文件:
java -jar Jenkins.war
Run Code Online (Sandbox Code Playgroud)
然后系统产生如下错误:
SEVERE: Running with Java class version 53.0, but 52.0 is required error
Run Code Online (Sandbox Code Playgroud)
任何人都知道我该如何解决这个问题?
我正在尝试使用 selenium 浏览器 python 获取 facebook 帐户的数据,但无法找到我可以在单击导出按钮时查找的元素。
我尝试过,但似乎给我的班级带来了错误。
def login_facebook(self, username, password):
chrome_options = webdriver.ChromeOptions()
preference = {"download.default_directory": self.section_value[24]}
chrome_options.add_experimental_option("prefs", preference)
self.driver = webdriver.Chrome(self.section_value[20], chrome_options=chrome_options)
self.driver.get(self.section_value[25])
username_field = self.driver.find_element_by_id("email")
password_field = self.driver.find_element_by_id("pass")
username_field.send_keys(username)
self.driver.implicitly_wait(10)
password_field.send_keys(password)
self.driver.implicitly_wait(10)
self.driver.find_element_by_id("loginbutton").click()
self.driver.implicitly_wait(10)
self.driver.get("https://business.facebook.com/select/?next=https%3A%2F%2Fbusiness.facebook.com%2F")
self.driver.get("https://business.facebook.com/home/accounts?business_id=698597566882728")
self.driver.get("https://business.facebook.com/adsmanager/reporting/view?act="
"717590098609803&business_id=698597566882728&selected_report_id=23843123660810666")
# self.driver.get("https://business.facebook.com/adsmanager/manage/campaigns?act=717590098609803&business_id"
# "=698597566882728&tool=MANAGE_ADS&date={}-{}_{}%2Clast_month".format(self.last_month,
# self.first_day_month,
# self.last_day_month))
self.driver.find_element_by_id("export_button").click()
self.driver.implicitly_wait(10)
self.driver.find_element_by_class_name("_43rl").click()
self.driver.implicitly_wait(10)
Run Code Online (Sandbox Code Playgroud)
您能告诉我如何单击“导出”按钮吗?
我想通过在 selenium webdriver 中按键盘键Ctrl+ Shift+来打开 chrome 浏览器控制台j。我可以使用Robot类来执行此操作,但我希望在没有Robot类的情况下执行此操作。我已经使用 sendKeys 使用了 Actions 类和 Keys 类。但我无法打开浏览器控制台。
是 chrome 浏览器版本问题还是操作系统?为什么浏览器控制台没有使用 Action 类和 Keys 类打开。?
selenium google-chrome google-chrome-devtools selenium-chromedriver selenium-webdriver
我正在通过“遵守测试山羊书”学习 TDD,但我正在尝试使用 Django 3。
如果有人知道的话,我在第6章。
我的代码是:
class VisitorTest(LiveServerTestCase):
def setUp(self):
self.browser = webdriver.Chrome()
self.browser.implicitly_wait(2)
def tearDown(self):
self.browser.quit()
def test_starting(self):
print(self.live_server_url)
self.browser.get(self.live_server_url)
Run Code Online (Sandbox Code Playgroud)
在控制台我得到
Creating test database for alias 'default'...
System check identified no issues (0 silenced).
DevTools listening on ws://127.0.0.1:52187/devtools/browser/e9a03a04-819e-40a3-a0e4-bd4133d8f6cb
http://localhost:52180
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 52204)
----------------------------------------
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 52202)
Exception happened during processing of request from ('127.0.0.1', 52203)
Traceback (most recent call last):
Traceback (most recent call last): …Run Code Online (Sandbox Code Playgroud) 我在 Linux 中通过 Selenium 使用 Chrome 时遇到以下错误:
ERROR:browser_main_loop.cc(1512)] Unable to open X display.
ERROR:nacl_helper_linux.cc(308)] NaCl helper process running without a sandbox!
Run Code Online (Sandbox Code Playgroud)
您有解决以下错误的方法吗?
推特中的所有主题都可以在这个链接中找到 我想用里面的每个子类别抓取。
BeautifulSoup 在这里似乎没有用。我尝试使用 selenium,但我不知道如何匹配单击主类别后出现的 Xpath。
from selenium import webdriver
from selenium.common import exceptions
url = 'https://twitter.com/i/flow/topics_selector'
driver = webdriver.Chrome('absolute path to chromedriver')
driver.get(url)
driver.maximize_window()
main_topics = driver.find_elements_by_xpath('/html/body/div[1]/div/div/div[1]/div[2]/div/div/div/div/div/div[2]/div[2]/div/div/div[2]/div[2]/div/div/div/div/span')
topics = {}
for main_topic in main_topics[2:]:
print(main_topic.text.strip())
topics[main_topic.text.strip()] = {}
Run Code Online (Sandbox Code Playgroud)
我知道我可以使用 来单击主类别main_topics[3].click(),但我不知道如何递归单击它们,直到我只找到Follow右侧的那些。