标签: webdriver

如何使用 webdriver 单击隐藏的下拉菜单元素,这不是选择

我想单击子菜单中的删除。

我尝试了下面的代码,但没有任何反应。

wd_handle.execute_script("document.getElementById('optionPanel').hidden=false;")
mouse.move_to_element(OptionPanel).perform()
WebDriverWait(wd_handle,10)
wd_handle.find_element_by_partial_link_text('Delete').click()
Run Code Online (Sandbox Code Playgroud)

HTML 源代码:

<div id="optionPanel" style="height: auto; width: auto; left: 126px; top: 368px; display: none; overflow-y: hidden;">'
 <div class="wrapper">
  <ul aria-hidden="false" role="menu">
   <li role="menuitem">
   <li role="menuitem">
   <li class="divider" role="menuitem">
    <a class="optionPanelLink" tabindex="0" 
    href="#playlistManager/action=delete/selected=701f55af-c5f0-4f31-b34f-964f52be5fef/idx=0">
    Delete</a>
   </li>
  </ul>
 </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我必须单击 id = 7ba9b231-5fc4-448b-b41a-f236437c182cCount 的元素才能使上述元素可见。

<li class="playlist viewing"> 
<a id="7ba9b231-5fc4-448b-b41a-f236437c182cLink" class="ellipsis" title="TestList2" href="#playList/name=TestList2/list=7ba9b231-5fc4-448b-b41a-f236437c182c">TestList2</a> 
<span class="entryCount">0</span> 
<a id="7ba9b231-5fc4-448b-b41a-f236437c182cCount" class="customPlaylistSpriteLocation optionSprite" href="#option/playlist=TestList2/selected=7ba9b231-5fc4-448b-b41a-f236437c182c/idx=0"></a> 
</li> 
Run Code Online (Sandbox Code Playgroud)

webdriver selenium-grid selenium-rc selenium-webdriver

1
推荐指数
1
解决办法
2541
查看次数

从 JavaScriptExecutor 从 ExecuteScript 获取值

我有一个问题,我需要从中获取价值

string someValue = ((IJavaScriptExecutor)Global.Driver).ExecuteScript("$('#publication_title').val();");

Console.WriteLine(someValue);
Run Code Online (Sandbox Code Playgroud)

任何的想法?

.net c# selenium webdriver

1
推荐指数
1
解决办法
6234
查看次数

如何对clojure/ring/selenium/leiningen进行集成测试?

我有一个 clojure/ring web 应用程序,我想用 clj-webdriver 测试它。有没有一种简单的方法来运行环网络服务器,然后运行测试,以便它们以环实例为目标?

我正在考虑一种用法,例如:

$ lein 带环测试

到目前为止,我有两个想法:

  1. 编写一个自定义的高阶 leiningen 插件。好像太复杂了。是否已经存在类似的插件?

  2. 编写一个 Makefile 规则来启动环,运行 lein 测试,找到并终止环进程 - 太复杂/hacky

有没有更简单的方法?

continuous-integration webdriver clojure leiningen

1
推荐指数
1
解决办法
769
查看次数

使用 CucumerJS 将文件上传到 WedriverIO 中的隐藏字段

嗨,我需要使用cucumberJS 和webdriverIO 自动化一个网站。为此,我需要上传一个文件,但该字段是隐藏的。例如 :

<input type="file" id='uploadFile' style="display: none"'>
Run Code Online (Sandbox Code Playgroud)

但 webdriver 无法识别 UI 上的元素。

提前致谢...

webdriver cucumber node.js selenium-webdriver cucumberjs

1
推荐指数
1
解决办法
944
查看次数

使用 Selenium 和 WebDriver 从 JAVA 中的 HTML 中获取隐藏文本

我试图从一个隐藏的跨度的 html 页面中获取文本。

<span class="hide"> Nike </span>
Run Code Online (Sandbox Code Playgroud)

我试过这样的事情:

WebElement element = driver.findElement(By.cssSelector(".product-page.clearfix > .hide > span"));
String content = (String)((JavascriptExecutor)driver).executeScript("arguments[0].innerHTML;", element);
product.setBrand(content)
Run Code Online (Sandbox Code Playgroud)

我也试过“ return arguments[0].innerHTML;”和“ element.getText()

我知道我可以使用纯 javascript,但这是一个简单的例子,我需要使用 WebDriver 和 Java 代码来处理更复杂的页面。

java.lang.ClassCastException: package.driver.DhlWebDriver cannot be cast to org.openqa.selenium.JavascriptExecutor
Run Code Online (Sandbox Code Playgroud)

html selenium webdriver hidden-field

1
推荐指数
1
解决办法
4011
查看次数

如何在 C# 中使用 WebDriver 获取指定元素的屏幕截图

我有一个用 Java 编写的小项目,我需要用 C# 重写它。

快完成了,但我坚持使用 Selenium webdriver 获取元素的屏幕截图。我在 Java 中采用了以下方式:

    public String saveImage(){
        String src = "";
        try{
            File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
            BufferedImage fullImg = ImageIO.read(screenshot);
            Point point = elementToScreent.getLocation();
            int eleWidth = elementToScreent.getSize().getWidth();
            int eleHeight = elementToScreent.getSize().getHeight();
            BufferedImage eleScreenshot= fullImg.getSubimage(point.getX(), point.getY(), eleWidth,
            eleHeight);
            ImageIO.write(eleScreenshot, "png", screenshot);
            src = path + System.currentTimeMillis() +".png";
            FileUtils.copyFile(screenshot, new File(src));
    }catch(Exception e){
        e.printstacktrace();
    }
    return src;
}
Run Code Online (Sandbox Code Playgroud)

它在 Java 中运行良好,但我不知道如何在 C# 中重写它,因为我对它不太熟悉。

有人可以建议一些很好的方法来在 C# 中实现相同的目标吗?

c# java selenium screenshot webdriver

1
推荐指数
1
解决办法
7465
查看次数

无法在 Python 中使用 Chrome 的 selenium Web 驱动程序打开两个具有不同配置文件的 Google Chrome 实例

我正在使用 Selenium WebDriver for Chrome 同时打开具有两个不同配置文件(配置文件 1 和配置文件 2)的 Google Chrome 的两个实例。配置文件 1 的第一个实例成功打开。但是,当我尝试使用 Profile 2 打开 Chrome 的第二个实例时,出现错误。

这是我的 Python 代码:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.options import Options

#Profile Directory for Google Chrome
dataDir = "--user-data-dir=C:\\Users\\Myname\\AppData\\Local\\Google\\Chrome\\User Data"

#Setting the Chrome options for Profile 1
chrome_options1 = Options()
chrome_options1.add_argument(dataDir)
chrome_options1.add_argument("--profile-directory=Profile 1")
driver1 = webdriver.Chrome(chrome_options=chrome_options1)

#This opens www.google.com sucessfully
driver1.get('https://www.google.com')


#Setting the Chrome options for Profile 2
chrome_options2 = Options()
chrome_options2.add_argument(dataDir)
chrome_options2.add_argument("--profile-directory=Profile 2")
#The below line …
Run Code Online (Sandbox Code Playgroud)

selenium google-chrome webdriver python-2.7

1
推荐指数
1
解决办法
3094
查看次数

Chrome Webdriver 在 Selenium 中产生超时

我正在尝试使用 Selenium 和 Chrome 的 webdriver 抓取网站,这一切都很好,直到我切换到更新的 Macbook。突然之间,webdriver 似乎无法识别网站何时真正完全加载。

错误信息如下

TimeoutException:消息:超时:无法根据超时确定加载状态:从渲染器接收消息超时:
-0.003(会话信息:chrome=54.0.2840.87)(驱动程序信息:chromedriver=2.25.426935(820a95b0b81d33e42712f912712f912712f91298c) 10.12.1 x86_64)

我的代码如下所示:

      import os
      import time
      from selenium import webdriver
      driver = webdriver.Chrome(os.path.join(os.getcwd(), 'chromedriver'))
      driver.get('http://www.clever-tanken.de/')
Run Code Online (Sandbox Code Playgroud)

selenium google-chrome webdriver

1
推荐指数
1
解决办法
2万
查看次数

python selenium - webdriver等到css_Selector可见

text = browser.find_element_by_css_selector('.dbaListing.listing.lastListing > td:nth-child(4) > span').text
Run Code Online (Sandbox Code Playgroud)

这就是我希望我的 webdriver 等待定位/可见的内容。我怎么做?

python selenium webdriver python-3.5

1
推荐指数
1
解决办法
4355
查看次数

尝试在Angular应用的VSCode中运行E2E时出现“ E /启动器-未创建会话:Chrome版本必须介于71和75之间”

我试图在VSCode中为Angular应用程序运行e2e(命令:ng e2e),但出现以下错误。

我的环境:

  • 赢10
  • VS代码版本:1.37.1
  • Chrome版本:76.0.3809.132版(正式版)(64位)

如何更新chromedriver以匹配Chrome版本?

Your global Angular CLI version (7.3.8) is greater than your local
version (7.3.5). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
 22% building 103/109 modules 6 active ...e\workflow-manager-table.component.scssBrowserslist: caniuse-lite is outdated. Please run next command `npm update caniuse-lite browserslist`

Date: 2019-09-03T18:20:59.131Z
Hash: 3ced9271ad10fcdd845e
Time: 14922ms
chunk {es2015-polyfills} es2015-polyfills.js, es2015-polyfills.js.map …
Run Code Online (Sandbox Code Playgroud)

webdriver selenium-webdriver protractor visual-studio-code angular

1
推荐指数
1
解决办法
421
查看次数