我长期以来一直在使用 Selenium webdriver 进行自动化操作。PhantomJS 驱动程序(现已弃用)是实现无头自动化的绝佳方式,而且您不需要像 chromedriver 和 chrome 浏览器那样将驱动程序版本与浏览器相匹配。我知道 chromedriver 和 firefox 驱动程序都可以在启用无头功能的情况下使用,但问题是它们的驱动程序需要不断升级并匹配当前浏览器版本的 os。请帮我。
我也很想知道是否有任何其他方式可以在没有任何依赖(独立)的情况下进行无头 Web 自动化。
与我的问题相关的编程语言是:1. Python 2. C# 3. VB.net 4. Java
如果有人对这四种语言中的任何一种或任何其他语言有任何想法或任何方式,请留下您的答案。
使用一个简单的 webscraper,我可以将我正在寻找的内容返回到我的脚本中的变量中content : content1。
出于某种原因,我无法在电子邮件正文中显示内容。
我试过使用message.attach(MIMEText(mail_content, 'text')) message.attach(MIMEText(mail_content, 'html'))它没有任何区别。还导入了time模块,因为我认为脚本中的延迟可能会有所帮助,但它没有。
from selenium import webdriver
import smtplib, ssl
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import time
DRIVER_PATH = 'C:/Users\James\Downloads\chromedriver_win32\chromedriver.exe'
driver = webdriver.Chrome(executable_path=DRIVER_PATH)
driver.implicitly_wait(5)
driver.get('https://www.skysports.com/football/news')
FootballHeadlines = driver.find_elements_by_class_name("news-list__headline-link")
for elem in FootballHeadlines:
print(elem.text)
print(elem.get_attribute("href"))
content = (elem.text)
content1 = (elem.get_attribute("href"))
sender_address = 'some@email'
sender_password = '**********'
receiver_email = 'someother@email'
message = MIMEMultipart()
message['From'] = sender_address
message['To'] = sender_address
message['Subject'] = 'Latest on Football'
session = …Run Code Online (Sandbox Code Playgroud) 我试图使用Selenium Webdriver-Java计算HTML表格中的总行数(不包括标题).
有人可以指导我关于相同步骤的正确方向吗?
提前致谢!
我知道水豚使用原生的,我需要为此安装 gem 吗?
我在搜索框中输入后尝试按 Enter
我有以下代码:
def test_counter(self):
try:
if self.driver.find_element_by_id(self.counter).text == 'texttexttext':
return True
except NoSuchElementException and StaleElementReferenceException:
self.fix_error()
return False
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚为什么NoSuchElementException或者StaleElementReferenceException没有被抓住.
如何检查 Appium 中元素的颜色代码/颜色? 我无法在 appium 中找到元素的颜色,因为在一个字段中我想自动化以不同颜色定义的输出。如何使用 Appium/UI automator 验证这一点。
在 Selenium 中,您可以使用部分 id 选择一个元素 '[id$=foobar]'
但是使用量角器你可以做到 element(by.id(foobar))
有没有办法使用量角器获得类似的功能。我无法在他们的文档中找到您是否可以执行类似element(by.id$(foobar)).
我正在尝试在 vs code 中使用此命令独立安装 selenium:
selenium-standalone install
Run Code Online (Sandbox Code Playgroud)
但它显示以下错误:
**
selenium-standalone install selenium-standalone : The term 'selenium-standalone' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1 + selenium-standalone install + ~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (selenium-standalone:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException****strong text****
**
Run Code Online (Sandbox Code Playgroud) 使用 MAC OS 我尝试使用 selenium firefox webdriver 打开新选项卡
url = "https://google.com"
mail = wd.Firefox()
mail.get(url)
time.sleep(1)
actions = ActionChains(mail) mail.find_element_by_xpath("/html/body/div[2]/div[2]/div[1]/h2/span[2]/span[1]").click()
time.sleep(1)
ActionChains(mail).key_down(Keys.COMMAND).send_keys('t').key_up(Keys.COMMAND).perform()
mail.close()
mail.quit()
Run Code Online (Sandbox Code Playgroud) 我已经成功安装了 TestNG 并在 eclipse (4.9.0) 中进行了确认。但是,在创建没有主类的基本类时,我在注释 @Test 处收到错误。即使导入测试注释包后,包上也存在错误。并且错误表明无法解决。 在此输入图像描述
selenium ×10
python ×4
java ×2
android ×1
annotations ×1
appium ×1
appium-ios ×1
automation ×1
c# ×1
capybara ×1
firefox ×1
macos ×1
node.js ×1
protractor ×1
ruby ×1
smtplib ×1
testing ×1
testng ×1
vb.net ×1