我正在处理下面的代码,奇怪的是它一直在打开Chrome浏览器而不是Firefox浏览器。
mysql --host=10.0.0.1 --user=root --password
我从下面的链接中获得了geckodriver,并将扩展名从.gz更改为.exe,我认为这是正确的,但是我不确定。.
import requests
import selenium
from selenium import webdriver
from bs4 import BeautifulSoup
from webbot import Browser
driver = webdriver.Firefox(executable_path= r'C:/path_here/geckodriver.exe')
web = Browser()
url = 'https://web_browser'
web.go_to(url)
# 1st validation
web.type('email_address' , into='username')
web.click('Continue')
# password
web.type('passwd' , into='password')
web.click('Next')
答案 0 :(得分:0)
此代码将打开Chrome浏览器窗口,因为:
“基于selenium框架的python Web自动化库”
如果您查看来源,则可以看到:
self.driver = webdriver.Chrome(executable_path=driverpath , chrome_options=options)
这意味着您将在这两行中打开两个标签:
driver = webdriver.Firefox(executable_path= r'C:/path_here/geckodriver.exe')
web = Browser()
您实际上并不需要。可以通过以下方式解决:
import requests
import selenium
from selenium import webdriver
from bs4 import BeautifulSoup
from webbot import Browser
web = Browser()
url = 'https://web_site'
web.go_to(url)
# 1st validation
web.type('email' , into='username')
web.click('Continue')
# 2nd validation
web.type('email' , into='username')
web.click('Next')
# password
web.type('pass' , into='password')
web.click('Next')
# Now you are logged in!!
url = 'https://web_page'
web.go_to(url)
# upload CSV Source File:
WebElement = web.driver.find_element_by_class_name('ignore-inline-attach')
web.driver.sendKeys("C:/my_path/test.csv");
# Close browser.
web.close_current_tag()
这不是Chrome问题。看看我对您之前的问题的回答!
致谢
答案 1 :(得分:0)
这最终为我工作。
from selenium import webdriver
profile = webdriver.FirefoxProfile()
profile.accept_untrusted_certs = True
wd = webdriver.Firefox(executable_path="C:/Utility/geckodriver.exe", firefox_profile=profile)
url = "https://www.google.com/"
wd.get(url)
# download geckodriver for windows 64-bit from here
# https://github.com/mozilla/geckodriver/releases
答案 2 :(得分:-2)
您必须添加这两个引用
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
之后,您可以像这样进行测试功能 使用OpenQA.Selenium; 使用OpenQA.Selenium.Firefox;
public void test()
{
IWebDriver browser = new FirefoxDriver();//Open Page
browser.Navigate().GoToUrl("https://stackoverflow.com");//Close Page
browser.Close();
}
希望我能为您提供帮助