selenium-webdriver

How to find element using type in Selenium and Python

青春壹個敷衍的年華 提交于 2020-05-13 05:27:21
问题 I have the below html code. <div align="center"> <input type="file" name="filePath"><br> <input type="Submit" value="Upload File"><br> </div> I am trying to find the two elements "file" and "submit" using Selenium with Python. Below is the code I have tried to use. from selenium import webdriver from selenium.webdriver.common.keys import Keys # create a new Firefox session driver = webdriver.Chrome() # Maximize the browser window driver.maximize_window() # Enter the url to load driver.get("<

scroll up the page to the top in selenium

牧云@^-^@ 提交于 2020-05-12 11:37:10
问题 How to scroll the webpage to the top of the page. I know scrolling the page to the bottom is: window.scrollTo(0,document.body.scrollHeight) just like that is it possible to scroll the page to the top 回答1: To scroll to the top of the page, just scroll to the 0, 0 : window.scrollTo(0, 0); Or, as an alternative option, you can scroll into view of the header element (or some other element on top): WebElement element = driver.findElement(By.tagName("header")); JavascriptExecutor js =

PDFBox IOException: End of File, expected line

ぐ巨炮叔叔 提交于 2020-05-12 04:38:32
问题 I am currently trying to grab text from a PDF that is already uploaded and accessed through a link by using PDFBox and Selenium. I used this as a source: http://www.seleniumeasy.com/selenium-tutorials/how-to-extract-pdf-text-and-verify-using-selenium-webdriver-java public String function(String pdf_url) { PDFTextStripper pdfStripper = null; PDDocument pDoc; COSDocument cDoc; String parsedText = ""; try { URL url = new URL(pdf_url); BufferedInputStream file = new BufferedInputStream(url

AWS Lambda Node.js 10.x Runtime error with selenium-webdriver

一曲冷凌霜 提交于 2020-05-11 17:08:11
问题 A few days back we received a notification regarding 'Lambda operational notification' to update our Node.js 8.10 runtime to Node.js 10.x runtime. In response to this notification, we installed Node.js version v10.16.3 in our development system and tested our existing code. We found the code was running fine in our development system, but when we tested this same code in AWS Lambda with Node.js 10.x runtime we get this following error: 2019-10-28T12:03:31.771Z 8e2472b4-a838-4ede-bc70

AWS Lambda Node.js 10.x Runtime error with selenium-webdriver

。_饼干妹妹 提交于 2020-05-11 17:06:17
问题 A few days back we received a notification regarding 'Lambda operational notification' to update our Node.js 8.10 runtime to Node.js 10.x runtime. In response to this notification, we installed Node.js version v10.16.3 in our development system and tested our existing code. We found the code was running fine in our development system, but when we tested this same code in AWS Lambda with Node.js 10.x runtime we get this following error: 2019-10-28T12:03:31.771Z 8e2472b4-a838-4ede-bc70

AWS Lambda Node.js 10.x Runtime error with selenium-webdriver

柔情痞子 提交于 2020-05-11 17:04:47
问题 A few days back we received a notification regarding 'Lambda operational notification' to update our Node.js 8.10 runtime to Node.js 10.x runtime. In response to this notification, we installed Node.js version v10.16.3 in our development system and tested our existing code. We found the code was running fine in our development system, but when we tested this same code in AWS Lambda with Node.js 10.x runtime we get this following error: 2019-10-28T12:03:31.771Z 8e2472b4-a838-4ede-bc70

Selenium Close File Picker Dialog

瘦欲@ 提交于 2020-05-10 18:39:09
问题 We are using Selenium-Webdriver on Jenkins box (running linux), to drive Firefox for testing a fairly complex web app. The web app requires the uploading of a photo for testing, and we have achieved that by using sendkeys to the input file dialog. Unfortunately (perhaps due to the way the uploader works, it is plupload and uploads through XHR and not a FORM post) the File Picker Dialog never closes. While this was slightly annoying, in the past the tests still passed fine. Switching from

Updating excel file using Apache POI

我是研究僧i 提交于 2020-05-10 04:26:12
问题 I am trying to update an existing excel file using Apache POI. Every time I run my code I receive an error as shown below. I have also tried FileInputStreamNewFile thing. Exception in thread "main" java.lang.NullPointerException at com.gma.test.WriteExcelTest.writeXLSXFile(WriteExcelTest.java:26) at com.gma.test.WriteExcelTest.main(WriteExcelTest.java:44) Please find the code below. Appreciate your help. package com.gma.test; import java.io.File; import java.io.FileInputStream; import java.io

How to check if some text is present on a web page using selenium 2?

自闭症网瘾萝莉.ら 提交于 2020-05-10 04:04:02
问题 Hi I am using selenium to automate test on web pages. I am using selenium 2 and python and would like to have answers in this framework only. SO how do I check whether some text is present or not? I have tried asset equals but it is not working? assertEquals(driver.getPageSource().contains("email"), true); 回答1: You can use driver.page_source and a simple regular expression to check if the text exists: import re src = driver.page_source text_found = re.search(r'text_to_search', src) self

How to check if some text is present on a web page using selenium 2?

↘锁芯ラ 提交于 2020-05-10 03:58:45
问题 Hi I am using selenium to automate test on web pages. I am using selenium 2 and python and would like to have answers in this framework only. SO how do I check whether some text is present or not? I have tried asset equals but it is not working? assertEquals(driver.getPageSource().contains("email"), true); 回答1: You can use driver.page_source and a simple regular expression to check if the text exists: import re src = driver.page_source text_found = re.search(r'text_to_search', src) self