私信  •  关注

DebanjanB

DebanjanB 最近创建的主题
DebanjanB 最近回复了
6 年前
回复了 DebanjanB 创建的主题 » 如何用css Selenium python选择innerText[duplicate]

这个错误说明了一切:

selenium.common.exceptions.InvalidSelectorException: Message: Given css selector expression "span:contains('Control panel')" is invalid: InvalidSelectorError: 'span:contains('Control panel')' is not a valid selector: "span:contains('Control panel')"

根据 Issue#987 Issue#1547 :

The :contains pseudo-class isn't in the CSS Spec and is not supported by either Firefox or Chrome (even outside WebDriver).

伪类是特定于 Sizzle Selector Engine 那个 Selenium 1.0 WebDriver 不会支持 Sizzle 风格 CSS selectors 硒1.0 使用。

:包含 pseudo-class 适用于不支持CSS选择器(IE7、IE8等)的浏览器 浏览器和选择器之间不一致。

<span> 标记如下:

element = "span[attribute_name=attribute_value]"

替代解决方案

您可以使用下列任一选项 X射线 DOM Tree :

  • 使用 text()

    element = my_driver.find_element_by_xpath("//span[text()='Control panel']")
    
  • 使用 contains() :

    element = my_driver.find_element_by_xpath("//span[contains(.,'Control panel')]")
    
  • 使用 normalize-space() :

    element = my_driver.find_element_by_xpath("//span[normalize-space()='Control panel']")
    

使用jQuery

jQuery公司 具体如下:

$('span:contains("Control panel")')

来自@FlorentB的宝贵评论。

控制台也不支持CSS选择器,但是 JQuery 支持它。这个 $('...') 从控制台是 document.querySelector JQuery公司 当页面拥有它时。

5 年前
回复了 DebanjanB 创建的主题 » Python Selenium——访问嵌套div中的文本

抽出文字 奥托米 你需要诱导 网络驱动器 visibility_of_element_located() 你可以使用下列任一方法 Locator Strategies

  • 使用 CSS_SELECTOR

    print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "a.jobs-details-top-card__company-url.ember-view[data-control-name='company_link'][href*='optomi']"))).text)
    
  • 使用 XPATH :

    print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//a[@class='jobs-details-top-card__company-url ember-view' and @data-control-name='company_link'][contains(@href,'optomi')]"))).text)
    
  • 注意

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
5 年前
回复了 DebanjanB 创建的主题 » Chrome在docker容器中返回状态码400

状态:400

状态:400 暗示 400 Bad Request 超文本传输协议 400 Bad Request 响应状态代码表示服务器无法或将不会处理该请求,原因可能是客户端错误,例如请求语法格式错误、请求消息帧无效或请求路由欺骗。


您的代码测试、相关的HTML和完整的错误堆栈跟踪中的一些信息可以帮助我们更好地分析问题。但是,根据 Failed to load resource: the server responded with a status of 400 () 看来 HTML DOM webpage 包含 AJAX JavaScript

所以当你调用 get() 网络驱动器 可点击的元素

  • 相关的 JavaScript AJAX调用 已完成渲染 DOM Tree
  • 所需的元素是 启用 看得见的 承认 click

您可以在中找到一些相关的讨论:


tl;博士

Failed to load resource: the server responded with a status of 429 (Too Many Requests) and 404 (Not Found) with ChromeDriver Chrome through Selenium

6 年前
回复了 DebanjanB 创建的主题 » Senium Python:理解对“rect”类型元素的访问

<rect>

这个 <rect> 元素是基本的 SVG

例如:

<svg viewBox="0 0 220 100" xmlns="http://www.w3.org/2000/svg">
  <!-- Simple rect element -->
  <rect x="0" y="0" width="100" height="100" />

  <!-- Rounded corner rect element -->
  <rect x="120" y="0" width="100" height="100" rx="15" ry="15" />
</svg>

属性

attributes 属于 <矩形>

  • x :此属性确定矩形的x坐标。
  • y :此属性确定矩形的y坐标。
    • 值类型:|;默认值:0;可设置动画:是
  • width
    • 值类型:auto | |;默认值:auto;可设置动画:yes
  • height :此属性确定矩形的高度。
    • 值类型:auto | |;默认值:auto;可设置动画:yes
  • rx
    • 值类型:auto | |;默认值:auto;可设置动画:yes
  • ry
    • 值类型:auto | |;默认值:auto;可设置动画:yes
  • pathLength :此属性允许以用户单位指定路径的总长度。
    • 值类型:;默认值:无;可设置动画:是

:从SVG2 x、y、width、height、rx和ry开始是几何属性,这意味着这些属性也可以用作该元素的CSS属性。


作为 <矩形> 元素是 元素,因此要定位此类元素,必须显式指定 SVG namespace 具体如下:

  • 为了 <svg>

    //*[name()="svg"]
    
  • 为了 <g> 元素:

    //*[name()="svg"]/*[name()="g"]
    
  • 为了 <矩形>

    //*[name()="svg"]/*[name()="g"]/*[name()="rect"]
    //*[name()="svg"]/*[name()="rect"]
    

工具书类

您可以在中找到一些相关的详细讨论

6 年前
回复了 DebanjanB 创建的主题 » 用selenium python单击按钮[复制]

单击文本为的按钮 在这个范围内 url 网络驱动器 对于 可点击的元素

  • 使用 CSS_SELECTOR

    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.b-btn.b-ghost"))).click()
    
  • 使用 XPATH :

    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='b-btn b-ghost' and contains(., 'Afficher plus')]"))).click()
    
  • 注意 :必须添加以下导入:

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
6 年前
回复了 DebanjanB 创建的主题 » Selenium Python:无法清除chrome浏览器缓存

在行尾添加“.click()”:

self.driver.find_element_by_css_selector("* /deep/ #clearBrowsingDataConfirm").click()

driver.find_element_by_xpath("//*[@id="clearBrowsingDataConfirm"]").click()

确定 分类表 网页上的类别 https://www.jtinsight.com/JTIRA/JTIRA.aspx#!/main 并打印类别标题,例如。 所有类别 , 汽车(私人) 等等,你需要 纸卷 降低一点并诱导 网络驱动器 对于 visibility_of_all_elements_located() 您可以使用以下解决方案:

  • 代码块:

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    
    options = webdriver.ChromeOptions() 
    options.add_argument("start-maximized")
    options.add_argument('disable-infobars')
    driver=webdriver.Chrome(chrome_options=options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
    driver.get("https://www.jtinsight.com/JTIRA/JTIRA.aspx#!/main")
    driver.execute_script("arguments[0].scrollIntoView(true);",WebDriverWait(driver, 30).until(EC.visibility_of_element_located((By.XPATH, "//span[@class='ng-scope' and text()='Classifieds']"))));
    print([elem.get_attribute("innerHTML") for elem in WebDriverWait(driver, 30).until(EC.visibility_of_all_elements_located((By.XPATH, "//div[@class='mainCatEntry']//div[@class='Description']")))])
    

此错误消息。。。

AttributeError: 'GoogleSearch' object has no attribute 'driver'

…意味着 单元测试 出现初始化错误。

我在你的代码块中没有看到这样的错误,但是 setUp() 方法。几句话:

  • def setUp(self): :的 设置() 是初始化的一部分,这个方法将在您将要在这个testcase类中编写的每个测试函数之前被调用。你拼错了 setUp(self) 作为 setUpp(self) .
  • 如果你正在使用 webdriver.Chrome() 你需要通过 绝对路径 铬河 但你提供了 壁虎 .
  • 当你经过 钥匙 executable_path 提供 价值 通过单引号和原始的 r 切换。
  • def tearDown(self): :的 tearDown() 方法在每个测试方法之后调用。这是执行所有清理操作的方法。
  • if __name__ == '__main__': :此行设置 __name__ 具有值的变量 "__main__" . 如果此文件是从另一个模块导入的,则 __姓名__ 将被设置为另一个模块的名称。
  • 您可以在中找到详细的讨论 What does if name == “ main ”: do?
  • 有了上述几点,您的有效代码块将是:

    import unittest
    from selenium import webdriver
    from selenium.webdriver.common.keys import Keys
    
    class GoogleSearch(unittest.TestCase):
    
        def setUp(self):
            self.driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe')
            self.driver.get('https://www.google.by')
            self.driver.maximize_window()
            self.driver.implicitly_wait(10)
    
        def test_01(self):
            driver = self.driver
            input_field = driver.find_element_by_class_name('class="gLFyf gsfi"')
            input_field.send_keys('python')
            input_field.send_keys(Keys.ENTER)
    
        def tearDown(self):
            self.driver.quit()
    
    if __name__ == "__main__":
        unittest.main()
    
  • 你可以在 Python + WebDriver — No browser launched while using unittest module

此错误消息。。。

WebDriverException: Message: unknown error: cannot connect to chrome at localhost:xxxx from session not created: Chrome version must be >= 69.0.3497.0 (Driver info: chromedriver=2.44.609538 (b655c5a60b0b544917107a59d4153d4bf78e1b90)

…意味着 Chrome版本必须>=69.0

你的主要问题是 版本兼容性 在您使用的二进制文件之间,如下所示:

  • 你在用 铬驱动=2.44 最理想的支持 版本之间的版本 69.x至71.x

解决方案

根据最佳实践:


更新A

如果你没有权限升级chrome并且你需要使用 铬v70 你必须下载匹配的 铬河 根据讨论中的细节进行修订 RemoteDisconnected(“Remote end closed connection without” http.client.RemoteDisconnected: Remote end closed connection without response


更新B

根据您的评论更新使用特定版本的 二进制通过提及安装路径,您可以在讨论之后 Cannot find Chrome binary with Selenium in Python for older versions of Google Chrome

6 年前
回复了 DebanjanB 创建的主题 » 如何在selenium python中单击span class text

单击文本为的元素 ê° ,您可以使用以下任一解决方案:

  • 使用 CSS_SELECTOR :

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.u_pg._more_btn_wrapper > a.u_pg_btn._btn_more span.u_pg_area span.u_pg_txt._more_txt"))).click()
    
  • 使用 XPATH :

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@class='u_pg _more_btn_wrapper']/a[@class='u_pg_btn _btn_more']//span[@class='u_pg_area']//span[@class='u_pg_txt _more_txt']"))).click()
    
  • 注意 :必须添加以下导入:

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
6 年前
回复了 DebanjanB 创建的主题 » 如何在selenium python中单击span class text

创建xpath的另一种方法-->

driver.find_element_by_xpath("//span[contains(@class,'u_pg_txt')]").click()
6 年前
回复了 DebanjanB 创建的主题 » python硒靓汤不还网站html

仅此一项就足以提取所需的文本。你需要诱导 网络驱动器 对于 visibility_of_element_located 您可以使用以下解决方案:

  • 代码块:

    from selenium import webdriver
    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.Firefox(executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')
    driver.get('https://investor.vanguard.com/529-plan/profile/4514')
    print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//tr[@class='ng-scope']//td[@class='ng-scope right']//span[@class='ng-scope ng-binding arrange' and @data-ng-bind-html]"))).get_attribute("innerHTML"))
    
  • 控制台输出:

    $42.91
    
6 年前
回复了 DebanjanB 创建的主题 » python硒靓汤不还网站html

你的使用方法没有什么问题 data_* 属性和值来选择范围。事实上,它是 documentation 。有4个跨度标记与所有属性匹配。 find_all 将返回所有这些标记。第二个对应于价格。

您遗漏的是,加载跨度需要一些时间,在此之前会返回页面源。你可以 explicitly wait 然后获取页面源。在这里,我使用xpath等待元素。您可以通过转到 inspect tool -> right click element -> copy -> copy xpath

from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from bs4 import BeautifulSoup
driver = webdriver.Firefox()
driver.get('https://investor.vanguard.com/529-plan/profile/4514')
WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH ,'/html/body/div[1]/div[3]/div[3]/div[1]/div/div[1]/div/div/div/div[2]/div/div[3]/div[1]/div/div/table/tbody/tr[1]/td[2]/div/span[1]')))
html = driver.page_source
soup = BeautifulSoup(html, 'html.parser')
myspan = soup.find_all('span', attrs={'data-ng-if': '!data.isLayer', 'data-ng-bind-html': 'data.value', 'data-ng-class': '{sceIsLayer : isETF, arrange : isMutualFund, arrangeSec : isETF}', 'class': 'ng-scope ng-binding arrange'})
print(myspan)
print(myspan[1].text)

产量

[<span class="ng-scope ng-binding arrange" data-ng-bind-html="data.value" data-ng-class="{sceIsLayer : isETF, arrange : isMutualFund, arrangeSec : isETF}" data-ng-if="!data.isLayer">Unit price as of 02/15/2019</span>, <span class="ng-scope ng-binding arrange" data-ng-bind-html="data.value" data-ng-class="{sceIsLayer : isETF, arrange : isMutualFund, arrangeSec : isETF}" data-ng-if="!data.isLayer">$42.91</span>, <span class="ng-scope ng-binding arrange" data-ng-bind-html="data.value" data-ng-class="{sceIsLayer : isETF, arrange : isMutualFund, arrangeSec : isETF}" data-ng-if="!data.isLayer">Change</span>, <span class="ng-scope ng-binding arrange" data-ng-bind-html="data.value" data-ng-class="{sceIsLayer : isETF, arrange : isMutualFund, arrangeSec : isETF}" data-ng-if="!data.isLayer"><span class="number-positive">$0.47</span> <span class="number-positive">1.11%</span></span>]
$42.91

此错误消息…

OSError: [WinError 1450] Insufficient system resources exist to complete the requested service

…意味着 python客户端 无法完成特定请求的服务。

这个错误似乎不是 相关但涉及 python客户端 以及潜在的 操作系统 .

但是,根据 "Insufficient System Resources Exist to Complete the Requested Service" Error on Windows 经常发生在 视窗10 操作系统当你长时间打开电脑,插入USB驱动器,或者当你试图启动一些.exe文件,如Chrome浏览器、iTunes、Microsoft Edge等时,电脑会冻结或结巴。重新启动电脑后,可能会再次发生错误并停止计算。


解决方案

最常用的两种方法如下:

a.修改注册表以修复“系统资源不足,无法完成请求的服务”

  • 如果Windows 10没有足够的内部内存资源来创建系统映像,则您将陷入系统错误“系统资源不足,无法完成请求的服务”。注册表修改可能会减轻痛苦。
  • 使用Windows快捷键 + R 开始跑步。
  • 键入 regedit
  • 按回车键。
  • 展开子项的条目: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\LanmanServer
  • 突出显示面板并右键单击空白窗格中的空白区域。
  • 选择新的和 DWORD (32位)值。
  • 将新条目命名为 maxworkitems .
  • 双击新条目并键入 1024 进入值数据框。
  • 单击“确定”。(注意:如果计算机内存小于512m,请在框中键入256。)

ModifyRegistry1

  • 转到子项: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management
  • 突出显示内存管理。
  • 在右侧,右键单击空白区域以创建新的区域。 双字 (32位)值。
  • 将新条目命名为 PoolUsageMaximum .
  • 将值数据更改为 60 然后选择decimal选项。
  • 单击“确定”。

ModifyRegistry2

  • 重新启动计算机。
  • 注释 :注册表编辑器是存储重要Windows数据的数据库。如果出现其他严重的系统错误,如黑屏问题、启动循环问题、“系统找不到指定文件”错误等,最好在修改前备份注册表。

B.扫描磁盘驱动器以修复错误

  • 错误的磁盘驱动器可能导致“系统资源不足以完成请求的服务”和其他存储问题,例如内存使用率高、内存泄漏问题、100%磁盘使用问题等。因此,可能需要进行扫描来检查磁盘。
  • 在Windows 10上打开这台电脑。
  • 右键单击 C: 驱动并选择属性。
  • 转到“工具”选项卡。
  • 单击复选按钮。
  • 单击扫描驱动器。

scan_disk_drive

  • 然后Windows 10将开始检查。如果发现错误,您可以按照屏幕上的指令来修复它们。
  • 之后,您还可以单击“优化”按钮 丙: 驱动器属性以优化驱动器。
6 年前
回复了 DebanjanB 创建的主题 » python selenium webdriver定位并单击链接

单击第四个链接,文本为 XLSP 您可以使用以下任一解决方案:

  • 使用 CSS_SELECTOR :

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "td a[onclick*='XP']"))).click()
    
  • 使用 XPATH :

    WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//a[contains(@onclick,'XP') and contains(.,'xlsp')]"))).click()
    
  • 注释 :必须添加以下导入:

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
6 年前
回复了 DebanjanB 创建的主题 » 带有selenium的python:无法定位元素

所需元素是 Angular 元素,所以要定位元素,你必须诱导 网络驱动器 对于 可点击的元素 您可以使用以下任一解决方案:

  • 使用 CSS_SELECTOR :

    element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.ng-pristine.ng-untouched.ng-valid.ng-empty[ng-change*='refreshTimeline']")))
    
  • 使用 XPATH :

    element = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//input[@class='ng-pristine ng-untouched ng-valid ng-empty' and contains(@ng-change,'refreshTimeline')]")))
    
  • 注释 :必须添加以下导入:

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
6 年前
回复了 DebanjanB 创建的主题 » 如何使用selenium和python通过a href提取文本

提取 文本 视频 您可以使用以下任一解决方案:

  • css_selector :

    driver.find_element_by_css_selector("a[href='/p/BrDudIUBuNr/'] span.glyphsSpriteVideo_large").get_attribute("aria-label")
    
  • xpath :

    driver.find_element_by_xpath("//a[@href='/p/BrDudIUBuNr/']//span[contains(@class,'glyphsSpriteVideo_large')]").get_attribute("aria-label")
    

此错误消息…

selenium.common.exceptions.WebDriverException: Message: invalid argument: can't kill an exited process

…意味着 壁虎司机 无法启动/生成新的 网络浏览会话 火狐浏览器 会话。

你的主要问题是 不相容 在您使用的二进制文件版本之间,如下所示:

  • 你的 壁虎司机 版本是 0.22.0 .
  • 发行说明 壁虎河V0.21.0(2018-06-15) 明确提到以下内容:

    • Firefox 57(及更高版本)

    • 硒3.11(及以上)

  • 你的 火狐 版本是 52.9 .

所以很明显 壁虎河V0.22.0 以及 Firefox浏览器V57


解决方案

  • 升级 壁虎司机 GeckoDriver v0.22.0 水平。
  • 壁虎在指定的位置。
  • Geckodriver对 非根 用户。
  • 升级 火狐 版本到 火狐V62.0.2 水平。
  • 干净的 你的 工程工作区 通过你 集成电路设备 重建 仅具有所需依赖项的项目。
  • 如果你的基地 网络客户端 版本太旧,请通过卸载 Revo Uninstaller 并安装最新的GA和发布版本的 网络客户端 .
  • 执行你的 硒试验 作为一个 非根用户 .

GeckoDriver , Selenium and Firefox Browser compatibility chart

supported_platforms_geckodriver_24

6 年前
回复了 DebanjanB 创建的主题 » 如何使用selenium+python加载动态内容

在Quora用户配置文件页上单击文本为的链接 (更多) 并检索用户答案您可以使用以下解决方案:

  • 代码块:

    from selenium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
    driver=webdriver.Firefox(executable_path=r'C:\Utility\BrowserDrivers\geckodriver.exe')
    driver.get("https://www.quora.com/profile/Ashley-Isabella-3")
    more_buttons = WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "a.ui_qtext_more_link")))
    for more_button in more_buttons:
        more_button.click()
    my_text_elements = WebDriverWait(driver, 20).until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, "div.ui_qtext_expanded>span.ui_qtext_rendered_qtext>p>b")))
    for my_text_element in my_text_elements:
        print(my_text_element.text)
    
  • 控制台输出:

    11 mistakes you make when trying to lose belly fat
    You could be doing the completely wrong exercise.
    1. You're not getting enough sleep
    2. You’re doing the wrong type of workout
    3. You’re consuming too much sugar
    4. You're not eating enough protein
    5. You’re feeling stressed or anxious
    6. You’re expecting a quick fix
    7. You’re not tracking your progress
    8. You’re crash-dieting
    9. You’re doing too much
    10. You haven't got the right exercise balance
    11. You’ve lost motivation
    
    9 Ways To Burn Fat Fast
    Implement these 9 fat-burning tips that use exercise and diet and watch the body fat melt like the butter you're no longer using.
    1. Stay Off The Scale
    2. Reduce Your Calories Gradually
    3. Vary Your Caloric Intake
    4. Train With Weights
    5. Do High-Intensity Intervals (HIIT)
    6. Eat More Fat
    7. Cut Carbs
    8. Increase Your Protein
    9. Eat 6 Smaller Meals Per Day, Not 2-3 Feasts
    Bonus:
    
    Researchers Explain 6 Reasons Why A Man Falls In Love
    1. HE’S CAPTIVATED BY THE WHOLE PACKAGE
    2. HE FEELS HE CAN MAKE HER HAPPY
    3. WHEN SHE’S OPEN TO LOVE
    4. THE WAY HE FEELS AROUND HER
    5. SHE SAYS “YES” TO LIFE
    6. HE FEELS PURPOSE AND PASSION
    Must Watch: Secret
    For You in Under 20 Minutes...
    These are the 7 weirdest things men find attractive in women
    Who knew anyone would ever find stubbornness attractive in a woman?
    1. Weakness
    2. Applying makeup
    3. Stubbornness
    4. Stretch marks
    5. Wearing glasses
    6. No make up
    7. Clumsiness
    Secret
    For You in Under 20 Minutes...
    5 surprising ways to get great skin
    There are so many bad ideas out there about how to achieve great skin. Here are five ways to get on the right track, regardless of 'the rules.'
    1. You don't need to wash your face with hot water to get it clean.
    2. Oil is good for your skin, not bad.
    3. You don't need to scrub to exfoliate.
    4. What matters most for healthy skin is not what you put on it, but what you eat.
    5. Chocolate doesn't cause acne, but bread and pasta might
    Make Your Skin Naturally Glow
    1. Skip the long, steamy showers and opt for shorter, cooler sprays.
    2. Check the dryness of your skin by scratching a small area on your arm or leg with your fingernail.
    3. Treat your neck and chest like an extension of your face.
    4. Run a humidifier every night in the winter to moisturize the air in your bedroom.
    
    12 easy tips for glowing skin
    1: Discover these glowing skin home remedies:
    2: Sweat it out for healthy skin
    3: Practice Yoga for Face Glow
    4: Know who you are!
    5: Follow a natural diet for glowing skin
    6: Indulge yourself…weekly
    7: Make Sudarshan Kriya your beauty mantra
    8: Meditate everyday to get Glowing Skin
    9: Silence is truly golden
    10: Save your mind at any cost
    11: 18 till I …why not?
    12: Flex those facial muscles
    15 Reasons Yoga Is Better Than The Gym
    1. Yoga benefits the mind, body and spirit.
    2. Yoga benefits your full body—externally and internally.
    3. Yoga teaches acceptance.
    4. Yoga is about focusing on yourself.
    5. Yoga will make you lean.
    6. Yoga is more efficient.
    7. You can do yoga anywhere.
    8. Yoga is kinder to the body.
    9. Yoga eases your aches and pains.
    10. Yoga helps you breathe easier.
    11. Yoga is calming.
    12. Yoga reduces stress.
    13. Everyone can practice yoga.
    14. Yoga improves concentration.
    15. Yogis rock.
    
    9 Ways to Tell If You’re Exercising Enough
    The sign: You never feel sore or tired the day after a workout
    The sign: You're not losing any weight
    The sign: You barely break a sweat
    The sign: The last rep feels hard, but you could probably do another
    The sign: You can chat with your friend throughout your workout
    The sign: You're not getting any more flexible in your yoga classes
    The sign: You run several days a week but aren't getting faster
    The sign: You're making strides in boot camp but are always stiff and un-flexible
    The sign: You take the same class regularly but aren't getting better at the exercises
    
    How To Build Muscle Mass After 50
    Exercise Plan
    Strength-Training Exercises
    Weight, Reps and Sets
    Aerobics Workouts
    
    Savannah Guthrie Says The Keto Diet Is Making Her Mind Sharp—And Her Body Sluggish
    She has zero desire to work out.
    
    How to Lose Weight in 10 Days at Home
    Flight of Stairs / Treadmill
    Lots of Water Fresh –
    Fruits and Vegetables –
    Low-Fat Foods Fish / Meat –
    Avoid Junk Food –
    Moderate Exercise -
    Drink lots of water -
    Day 1
    Day 2 and 3
    Day 4 and 5
    Day 6 and 7
    Day 8 and 9
    Day 10
    
    What are natural ways to make my face look younger?
    Smoothing Exfoliator
    Tightening Toner
    Plumping Moisturizing Facial Mask
    
    10 Ways to Lose 25 Pounds
    Follow these steps and weight loss won’t seem impossible.
    1. Do some detective work.
    2. Get moving.
    3. Plan ahead.
    4. Fill up on fruits and veggies.
    5. Don’t drink your calories.
    6. Don’t do anything drastic.
    7. Set smart calorie targets.
    8. Keep track.
    9. Do not make weight the only measure of success.
    10. Just practice; don’t try to be perfect.
    

你好像快到了。

保留你的概念 滚动 通过 scrollIntoView() 印刷 一些有用的调试消息,我做了一些小的调整,包括 网络驱动器 您可以使用以下解决方案:

  • 代码块:

    from selenium import webdriver
    from selenium.webdriver.chrome.options import Options
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    
    options = Options()
    options.add_argument("start-maximized")
    options.add_argument('disable-infobars')
    options.add_argument("--disable-extensions")
    driver = webdriver.Chrome(chrome_options=options, executable_path=r'C:\Utility\BrowserDrivers\chromedriver.exe')
    driver.get("https://www.amazon.com/s/ref=nb_sb_noss_1?url=search-alias%3Daps&field-keywords=sonicare+toothbrush")
    while True:
        try:
            current_page_number_element = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "span.pagnCur")))
            driver.execute_script("arguments[0].scrollIntoView(true);", current_page_number_element)
            current_page_number = current_page_number_element.get_attribute("innerHTML")
            WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "span.pagnNextArrow"))).click()
            print("page # {} : going to next page".format(current_page_number))
        except:
            print("page # {} : error, no more pages".format(current_page_number))
            break
    driver.quit()
    
  • 控制台输出:

    page # 1 : going to next page
    page # 2 : going to next page
    page # 3 : going to next page
    page # 4 : going to next page
    page # 5 : going to next page
    page # 6 : going to next page
    page # 7 : going to next page
    page # 8 : going to next page
    page # 9 : going to next page
    page # 10 : going to next page
    page # 11 : going to next page
    page # 12 : going to next page
    page # 13 : going to next page
    page # 14 : going to next page
    page # 15 : going to next page
    page # 16 : going to next page
    page # 17 : going to next page
    page # 18 : going to next page
    page # 19 : going to next page
    page # 20 : error, no more pages
    
6 年前
回复了 DebanjanB 创建的主题 » selenium python html解析:使用$ctrl访问元素

提取文本 阿尔法电子竞技 ,因为元素是 Angular 元素,你必须诱导 网络驱动器 对于 定位元素的可见性 您可以使用以下任一解决方案:

  • CSS_SELECTOR :

    myText = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "div.ui-scoreboard-coupon-template__content--vertical-aligner div:nth-child(2) ui-scoreboard-runner.ui-scoreboard-runner.ui-scoreboard-runner__home>span[ng-class]"))).get_attribute("innerHTML")
    
  • XPATH :

    myText = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.XPATH, "//div[@class='ui-scoreboard-coupon-template__content--vertical-aligner']//following::div[2]//ui-scoreboard-runner[@class='ui-scoreboard-runner ui-scoreboard-runner__home']/span[@ng-class]"))).get_attribute("innerHTML")
    
  • 注意:必须添加以下导入:

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
7 年前
回复了 DebanjanB 创建的主题 » 如何在python web驱动程序[duplicate]中解决此错误

在工作时 硒V3.11.0 , Chromedriver 2.36版 铬V64 你必须下载最新的 铬合金驱动器 ChromeDriver - WebDriver for Chrome 把它放在你的系统里。初始化时的下一步 网络驱动程序 以及 控件 你必须通过辩论 executable_path 以及 铬合金驱动器 如下:

from selenium import webdriver

driver = webdriver.Chrome(executable_path='/path/to/chromedriver')
driver.get("http://www.python.org")
6 年前
回复了 DebanjanB 创建的主题 » 无法单击按钮python selenium

这个 按钮在我的机器人上创建签出 好像是 信用卡 相关领域和历史 信用卡 相关字段位于 <iframe> .

您可以在中找到一些相关的讨论:

所以如果所需的元素在 <iFrAME> 所以你必须:

  • 诱导 网络驱动器 为了想要的 框架可用并切换到它 .
  • 诱导 网络驱动器 为了想要的 可点击的元素 .
  • 您可以使用以下任一解决方案:

    • 使用 CSS_SELECTOR :

      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe_css_selector")))
      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "label[for='VISA']"))).click()
      
    • 使用 XPATH :

      WebDriverWait(driver, 20).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe_xpath")))
      WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//label[@for='VISA']"))).click()
      
  • 注释 :必须添加以下导入:

    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
6 年前
回复了 DebanjanB 创建的主题 » 如何使用selenium python激活inspect窗口?

在c中创建chromedriver对象时,这将起作用,
您需要通过在chromeoptions中添加参数来提供配置文件,

ChromeOptions options = new ChromeOptions();
options.AddArguments("--auto-open-devtools-for-tabs");
browser = new ChromeDriver(DrivePath, options, TimeSpan.FromSeconds(100));

您也可以尝试按F12,它将打开“检查”窗口 然后你可以使用机器人类或窗口。用于自动化脚本的表单库管理多个窗口表单。

你的代码在Python中,同样的答案是为Java和C语言提供的。
更多信息,请访问:

7 年前
回复了 DebanjanB 创建的主题 » 在SeleniumWeb驱动程序python中打开相同的会话[重复]

,无法重新连接到上一个 Web Browser 退出脚本后的会话。即使你能提取 Session ID , Cookies 以及上一个会话的其他属性 Browsing Session 但是,您仍然无法将这些属性作为钩子传递给 WebDriver .

一个更干净的方法是打电话 webdriver.quit() 然后跨越一个新的 浏览会话 .

历史记录:

以前有过一些讨论,并试图重新连接 Web驱动程序 到正在运行的现有浏览会话。您可以在以下QA中找到讨论:

6 年前
回复了 DebanjanB 创建的主题 » 如何通过Selenium和Python在Gas Day输入框中输入日期

发送 日期 作为一个 字符序列 天然气日 你需要诱导的场 网络驱动器等待 为所期望的 要点击的元素 您可以使用以下解决方案:

  • 代码块:

    from selenium import webdriver
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    
    options = webdriver.ChromeOptions() 
    options.add_argument("start-maximized")
    options.add_argument('disable-infobars')
    browser = webdriver.Chrome(chrome_options=options, executable_path=r'C:\WebDrivers\chromedriver.exe')
    browser.get("http://ips.alliance-pipeline.com/Ips/MainPage.aspx?siteId=4")
    browser.find_element_by_id('treeviewn0').click() # click on "Capacity" heading
    browser.find_element_by_id('treeviewt1').click() # click on "Daily Throughput" heading
    WebDriverWait(browser, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input.igte_EditInContainer"))).send_keys("10/04/2018")
    
  • 浏览器快照:

date

6 年前
回复了 DebanjanB 创建的主题 » 如何使用python selenium webdriver在li中获取跨度的值?

价值 SCN 89862530个 反映在3个不同的地方,你可以从其中一个地方提取 网络驱动器等待 对于 visibility_of_element_located() 你可以使用以下任何一种 Locator Strategies :

  • <map-hs-label-value> 标签 map-hs-lv-value 属性:

    print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located()((By.XPATH, "//div[@class='hs-customerdata hs-customerdata-pvalues']/ul/li/map-hs-label-value"))).get_attribute("map-hs-lv-value"))
    
  • <span> 标签 map-v-key 属性:

    print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located()((By.XPATH, "//div[@class='hs-customerdata hs-customerdata-pvalues']/ul/li/map-hs-label-value//span[@class='hs-attribute-value']"))).get_attribute("map-v-key"))
    
  • <跨度> 用文本标记为 89862530 :

    print(WebDriverWait(driver, 20).until(EC.visibility_of_element_located()((By.XPATH, "//div[@class='hs-customerdata hs-customerdata-pvalues']/ul/li/map-hs-label-value//span[@class='hs-attribute-value']"))).get_attribute("innerHTML"))