ghostdriver

PhantomJS - 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive

浪尽此生 提交于 2019-12-01 17:18:35
I'm trying to change the value of a input with PHP webdriver and PhantomJS. When I run a simple $driver->executeScript("document.getElementById('changeme').value='".$newvalue."' ;", array()); I get the following error Refused to evaluate a string as JavaScript because unsafe-eval is not an allowed source of script in the following Content Security Policy directive I've got the following command line options set --ignore-ssl-errors=true --web-security=false --ssl-protocol=any Any suggestions? 来源: https://stackoverflow.com/questions/28593216/phantomjs-unsafe-eval-is-not-an-allowed-source-of

How do you create a browser profile for Selenium's PhantomJS/GhostDriver?

≯℡__Kan透↙ 提交于 2019-12-01 15:22:23
Here's how you create a Firefox profile: fp = webdriver.FirefoxProfile() fp.set_preference("browser.download.folderList",2) fp.set_preference("browser.download.dir", download_dir) fp.set_preference("browser.download.manager.showWhenStarting",False) fp.set_preference("browser.helperApps.neverAsk.saveToDisk","text/csv") How do you do it with PhantomJS (GhostDriver)? luksch The closest you can get with phantomjs is to use the driver capabilities: DesiredCapabilities caps = DesiredCapabilities.phantomjs(); caps.setCapability( "phantomjs.page.settings.userAgent", "Mozilla"); Set<String> cliArgs =

How to set screen/window size when using GhostDriver

霸气de小男生 提交于 2019-12-01 08:48:16
I am using the GhostDriver as the WebDriver implementation in a Java-based project. I want to take snapshots of the pages. The default page size is kind of awkward, so I want to control the page size of the snapshots. However, I can't find any examples from Google. So, can someone tell me how? Thank you very much. Have you tried setSize() method from WebDriver.Window ? Here is the documentation. // untested Java code, only provides the logic // please debug and refer to the documentation import org.openqa.selenium.Dimension; WebDriver driver = new PhantomJSDriver(); driver.manage().window()

How to set screen/window size when using GhostDriver

为君一笑 提交于 2019-12-01 07:17:07
问题 I am using the GhostDriver as the WebDriver implementation in a Java-based project. I want to take snapshots of the pages. The default page size is kind of awkward, so I want to control the page size of the snapshots. However, I can't find any examples from Google. So, can someone tell me how? Thank you very much. 回答1: Have you tried setSize() method from WebDriver.Window ? Here is the documentation. // untested Java code, only provides the logic // please debug and refer to the documentation

Handling Redirection w/ PhantomJS + Selenium

落爺英雄遲暮 提交于 2019-11-30 23:23:40
I currently run browser tests via PhantomJS + Selenium in Python. desired_capabilities = dict(DesiredCapabilities.PHANTOMJS) desired_capabilities["phantomjs.page.settings.userAgent"] = ("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/40.0.2214.115 Safari/537.36") driver = webdriver.PhantomJS(executable_path="./phantomjs", desired_capabilities=desired_capabilities) driver.get('http://google.com') This works fine, unless the page I'm trying to get has a redirect on it. Example: https://login.vrealizeair.vmware.com/ In this case, the get doesn't work

Need to dump entire DOM tree with element id from selenium server

末鹿安然 提交于 2019-11-30 12:16:26
问题 I have been using python selenium for web automation testing. The key part of automation is to find the right element for a user-visible object in a HTML page. The following API will work most of the time, but not all the time. find_element_by_xxx, xxx can be id, name, xpath, tag_name etc. When HTML page is too complicated, I would like to search the dom tree. Wonder if it's possible to ask the selenium server to serialize the entire DOM (with the element id that can be used to perform action

Selenium with GhostDriver in Python on Windows

对着背影说爱祢 提交于 2019-11-30 12:06:58
This is embarrassing to ask because it seems like something with so slim chance of error. I wouldn't think this would be difficult, but I've been plugging away at this for almost 3 hours now and it's giving me a headache. I've read several dozen stackoverflow threads and Google threads. I've installed PhantomJS, added it to my System Variables PATH, and it works properly in the command line. I also installed Selenium earlier with easy_install. The error I get is: __init__ C:\Python27\lib\site-packages\selenium-2.39.0-py2.7.egg\selenium\webdriver\phantomjs\webdriver.py 50 start C:\Python27\lib

How can I handle an alert with GhostDriver via Python?

对着背影说爱祢 提交于 2019-11-30 09:25:54
Problem: The GhostDriver API does not yet support alert handling. There is an acceptable workaround for the time being, which is to inject your own javascript into the page that will handle the alert and store it's text for you. I'm having trouble using this workaround via the python webdriver bindings. It might be related to my novice level understanding of javascript. Here is an example of the workaround I am trying to utilize: https://github.com/detro/ghostdriver/issues/20#issuecomment-15641983 I'm using a public site that demonstrates an alert to make this more straightforward: http://www

Using Selenium in the background

有些话、适合烂在心里 提交于 2019-11-30 07:13:31
问题 I'm using Selenium and chrome webdriver but when I run scripts it opens a window. Is there any way that it can access the internet without the window popping up? from selenium import webdriver from selenium.webdriver.common.keys import Keys driver = webdriver.Chrome() driver.get("https://ps.rsd.edu/public/") elem = driver.find_element_by_name("account") elem.send_keys("Username") elem2 = driver.find_element_by_name("pw") elem2.send_keys("Password") elem.send_keys(Keys.RETURN) driver.quit()

Unable to launch HtmlUnitdriver through Selenium 3.4.0

假如想象 提交于 2019-11-29 18:49:27
I am tried to run the HtmlUnitDriver with selenium 3.4 and chrome Version 64.0.3282.119 (Official Build) (32-bit). My code is: package eclipse; import java.io.File; import org.openqa.selenium.By; import org.openqa.selenium.Capabilities; import org.openqa.selenium.UnexpectedAlertBehaviour; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.phantomjs.PhantomJSDriver; import org.openqa.selenium.remote.CapabilityType; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.htmlunit.HtmlUnitDriver; import org.testng