问题标签 [findelement]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
1 回答
62 浏览

selenium - selenium python如何查找和单击每次更改的元素

我试图找到一个具有动态值的元素,例如<span class="ms-Button-label label-175" id="id__177">Save</span> 在检查元素中,id 和 class 值往往会随着每次刷新而改变,在这种情况下我如何才能找到 selenium 中的元素?我尝试了troguht xpath,但似乎不起作用,因为找不到路径,我想找到xpath总是找到“保存”世界,但实际上我不知道我是否做得很好:driver.find_element_by_xpath(//span(@.... 但是呢?如果每次都更改,如何插入元素?谢谢!

0 投票
1 回答
994 浏览

python - Selenium:driver.find_elements_by_xpath() 和 driver.find_elements_by_class_name() 之间的区别

我有个问题:

我认为两者的工作方式相同,但是当我运行它们时,第一个返回了一些元素,而第二个返回了一个空列表。

0 投票
0 回答
40 浏览

python - 如果我想发送文本我应该找到什么_element_by_?

如果我想在标签中发送文本我应该找到什么元素?

在此处输入图像描述

0 投票
1 回答
160 浏览

python - 如果 browser.find_element_by_xpath 没有数据或无法定位元素时条件不起作用

  1. browser.find_element_by_xpath('//div[@id="MainCopy_ctl13_presentJob_EmailAddressPanel"]//a')).get_attribute("textContent")没有数据。

  2. 如果我们在提供的 xpath 中没有数据,我写了一个条件,它应该替换为“无数据”。

  3. 如果存在数据,我们需要存储电子邮件地址,否则我们需要存储默认值(即)“无数据”

  4. 这是我每次都收到的错误。

selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:无法找到元素:{"method":"xpath","selector":"//div[@id="MainCopy_ctl13_presentJob_EmailAddressPanel"]//a"} (会话信息:chrome=88.0.4324.150)

0 投票
1 回答
119 浏览

java - selenium 中的 cssSelector 和 ByCssSelector 有什么区别

下面代码中的 By.cssSelector 和 By.ByCssSelector 有什么区别。

driver.findElement(By.cssSelector("test")).click(); driver.findElement(By.ByCssSelector.id("")).click();

0 投票
1 回答
62 浏览

c# - Multiple IWebElements with same class all point to the first one

I'm using Selenium in C#, to try and get the values from a table on the web into a local table.

I get all the rows using:

#xA;

I can see that allTableRows has multiple different rows, differing by ID and text. But then, when I try to iterate over them, and gather data for each row with:

#xA;

Every item in my final list has the same data, the ones from the first row. (Even though the original table had different date/time values in each row)

There are no additional selectors to be used like specific id/class, so I am forced to use general rules (rows by class name, and then cells in each row only differing in [0], [1], [2]...etc)

I'm not sure why the data always points to the first row, since we are trying to get elements in a foreach, for that specific row.

0 投票
2 回答
745 浏览

python-3.x - Python + Selenium find_element_by_xpath 返回字典

-版本- Python:3.6.8 Selenium:3.141.0

我试试这个。

但,

AttributeError:“dict”对象没有属性“text”

我知道.... find_element~ 函数返回 Dict 类型,而不是 WebElement。

有什么问题?

0 投票
0 回答
22 浏览

python - Selenium - driver.find_element_by_css_selector 在 Python 中找不到元素

我们有 JSS (CSS) 类,有没有办法找到元素?:以下是代码:

分别尝试了所有这些:

没有工作,任何帮助将不胜感激,谢谢。

0 投票
0 回答
44 浏览

python - MobileBy.ANDROID_UIAUTOMATOR 不可调用

我想跑

但它给出了以下错误:

MobileBy.ANDROID_UIAUTOMATOR 不可调用

有什么问题?!

0 投票
1 回答
48 浏览

python - 如何在 selenium Safari() 中找到此元素

这是页面https://www.wunderground.com/weather/gb/london我想点击历史。 这是我检查元素历史时得到的

没有一个查找元素方法有效,我的脚本总是出现无效的语法。我怎样才能找到元素并选择它?谢谢