webdriver

How to take screenshots and paste it in a word file one by one using webDriver (java)

拥有回忆 提交于 2020-06-25 07:29:31
问题 I am able to take screenshot by ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); In my application I have to take screenshot for every page so I want to save the multiple screenshot into a single .doc file one by one. Is there any API? Any Idea? Please Help... 回答1: Easiest way - take screenshot, put it in PNG/JPEG file, read it, add it in MS-Word, delete the file, simple. here's a ready to use code for you.... BINGO...!! import java.awt.Rectangle; import java.awt.Robot; import java

Downloading file through Selenium Webdriver in python

不羁岁月 提交于 2020-06-22 12:56:47
问题 I am writing a program to automate web interaction through selenium webdriver in python. I got stuck in last step when I click on the "download" button through script, a window pop-up occours on the screen,with default option "Open with" selected. I want my program to first click on the option "save file" and then click on "OK". I have used following piece of code to set up Firefox profile profile = webdriver.FirefoxProfile() profile.set_preference('browser.download.folderList', 2) profile

Selenium Webdriver in c# usage of Sessionid

笑着哭i 提交于 2020-06-18 19:01:28
问题 What is the Use of SessionID in Selenium Webdriver? Consider a scenario having opened 5 Browsers each having its own sessionid. Can we use these sessionid's to close their respective browsers ? if so, how do we do that in C# ? 回答1: Having session ID handy could help you connect with your session on a remote web driver. You can fetch the session ID with : var sessionIdProperty = typeof(RemoteWebDriver).GetProperty("sessionId", BindingFlags.Instance | BindingFlags.NonPublic); //sessionId if

python selenium can't clear input field

爱⌒轻易说出口 提交于 2020-06-17 09:47:45
问题 I try to select my input with selenium but when I use this it doesn't work: driver = self.driver password = driver.find_element_by_xpath("//input[@name='password']") password.clear() password.send_keys(password) password.send_keys(Keys.RETURN) # the sentence below doesn't work password.send_keys(Keys.COMMAND, 'a') password.send_keys(Keys.DELETE) I am using Mac so Keys.CONTROL doesn't work, can anyone help me how to select the input or how to clear it? Thanks 回答1: Mac cannot use COMMAND you

WebDriverException: Message: Service /usr/bin/google-chrome unexpectedly exited. Status code was: -11 with ChromeDriver Chrome through Selenium Python

心不动则不痛 提交于 2020-06-17 01:59:47
问题 I am trying to run webdriver in a Python script, and when the script tries to run google chrome it exits with status code 11. Here is the python script: #!/usr/bin/python3 import time from selenium import webdriver driver = webdriver.Chrome('/usr/bin/google-chrome') # Optional argument, if not specified will search path. driver.get('http://www.google.com/'); time.sleep(5) # Let the user actually see something! search_box = driver.find_element_by_name('q') search_box.send_keys('ChromeDriver')

WebDriverException: Message: Service /usr/bin/google-chrome unexpectedly exited. Status code was: -11 with ChromeDriver Chrome through Selenium Python

时间秒杀一切 提交于 2020-06-17 01:59:10
问题 I am trying to run webdriver in a Python script, and when the script tries to run google chrome it exits with status code 11. Here is the python script: #!/usr/bin/python3 import time from selenium import webdriver driver = webdriver.Chrome('/usr/bin/google-chrome') # Optional argument, if not specified will search path. driver.get('http://www.google.com/'); time.sleep(5) # Let the user actually see something! search_box = driver.find_element_by_name('q') search_box.send_keys('ChromeDriver')

Selenium: Save and Load LocalStorage to/from File

不羁岁月 提交于 2020-06-13 08:32:25
问题 I'm currently writing a script in python to tell me how many unread messages I have in WhatsApp. To get the count of unread messages selenium opens web.whatsapp.com however I have to authenticate every time. I found out that WhatsApp saves the data to authenticate in the LocalStorage so I'm trying to figure out how I can save the contents from LocalStorage to a file and then later read from it and set all the keys. I tried: localStorage = driver.execute_script('return window.localStorage;')

Windows popup interaction for downloading using selenium webdriver in python

强颜欢笑 提交于 2020-06-12 07:43:06
问题 I am making a programme to automatically download the data using selenium webdriver in python. When i click on "download" button following popup occours . with default option "Open with" selected. I want my program to first click on the option "save file" and then click on "OK". I have used following piece of code to set up Firefox profile profile = webdriver.FirefoxProfile() profile.set_preference('browser.download.folderList', 2) profile.set_preference('browser.download.manager

What is the difference between driver.switchTo().parentFrame() and driver.switchTo().defaultContent() method in Selenium WebDriver?

大兔子大兔子 提交于 2020-06-10 05:27:09
问题 What is difference between below two methods : driver.switchTo().parentFrame(); driver.switchTo().defaultContent(); 回答1: driver.switchTo().parentFrame(); As per the specifications, driver.switchTo().parentFrame(); invokes the following: Where, the Switch to Parent Frame command sets the current browsing context for future commands to the parent of the current browsing context . As per the Java Docs parentFrame() method changes the focus to the parent context. If the current context is the top

chromedriver window.navigator.webdriver flag is true with chrome v80+

佐手、 提交于 2020-06-09 05:24:42
问题 I am using selenium chromeDriver for automated testing. But I cannot "hide" the window.navigator.webdriver property. When I open chrome(v64-80.0.3987.100) through the driver, it always returns true when viewed in the console. Here is my code: System.setProperty("webdriver.firefox.marionette", "false"); System.setProperty("webdriver.chrome.driver", webDriverPath); ChromeOptions options = new ChromeOptions(); options.addArguments("--no-sandbox"); options.addArguments("--disable-extensions");