Using firefox and selenium with tor anonymously
Apparently using other applications with tor is not recommended . I followed method 2 instruction three from here and simply changed my socks host port to 9150 in firefox, so that it would match my tor brower port. According to this answer, it looks like it might be fine, but it looks like it's saying that tor has it's own version of firefox?
I'm running tor with selenium using the following commands, these commands just return a random IP address that I'm routing through
profile=webdriver.FirefoxProfile()
profile.set_preference('network.proxy.type', 1)
profile.set_preference('network.proxy.socks', '127.0.0.1')
profile.set_preference('network.proxy.socks_port', 9150)
driver=webdriver.Firefox(profile)
driver.get("http://icanhazip.com")
print(driver.page_source)
driver.close()
See also questions close to this topic
-
What does it mean if a method returns browser.page?
I wanted to start practicing some more of GEB/selenium best practices.
I found some documentation that I am trying to mimic but I am not getting the desired result and I believe it may be do to my misunderstanding.
I found this code snippet here:
class HomePage extends geb.Page { static content = { loginLink(to: LoginPage) { $("#login_link") } } LoginPage clickLoginLink() { loginLink.click() return browser.page } }
class LoginPage extends geb.Page { static content = { usernameField { $("#username") } passwordField { $("#password") } loginButton(to: DashboardPage) { $("#login_button") } } DashboardPage login(String username, String password) { usernameField.value(username) passwordField.value(password) loginButton.click() return browser.page } }
It then goes on to say that this structure allows you to make this call:
DashboardPage dashboardPage = to(HomePage).clickLoginLink().login('user1', 'password1')
I have tried to set up something slightly similar the code is as follows:
Page:
class LoginPage extends Page { static at = { $(By.xpath("//h1[text()='Welcome to Your Company JIRA']")).displayed } static url = "http://localhost:2990/jira/login.jsp" static content = { LOGIN_USER {$(By.id("login-form-username"))} LOGIN_PASS {$(By.id("login-form-password"))} LOGIN_BTN (to: SystemDashboardPage, toWait:10) {$(By.id("login-form-submit"))} banner {module JiraBanner} } def logIn(user, pass){ LOGIN_USER.value(user) LOGIN_PASS.value(pass) LOGIN_BTN.click() return browser.page } }
Script:
class Test extends GebReportingSpec { //The Pages we will use for this test @Shared def loginPage = new LoginPage() def systemDashboardPage = new SystemDashboardPage() def "Login to Jira"(){ when: "we navigate to Jira Login" loginPage = to LoginPage and: "we login" systemDashboardPage = loginPage.logIn("admin", "admin") then: "We should be at the home page" assert systemDashboardPage instanceof SystemDashboardPage } } def "Navigate to Issues Admin Page"(){ when: "we Navigate to the Admin Issues Page" issuesAdminsPage = systemDashboardPage.banner.goToIssuesAdmin() then: "we should be at the issue admin Page" assert issuesAdminsPage instanceof IssuesAdminPage }
When I run this code though I get:
Instance of page class Pages.SystemDashboardPage has not been initialized. Please pass it to Browser.to(), Browser.via(), Browser.page() or Browser.at() before using it. geb.error.PageInstanceNotInitializedException: Instance of page class Pages.SystemDashboardPage has not been initialized. Please pass it to Browser.to(), Browser.via(), Browser.page() or Browser.at() before using it.
From what I can understand from the example, returning browser.page should be initializing the page since I added the
to
flag to the static content.What am I missing here?
-
How can I automate a project developed in Swift?
How can I automate project developed in Swift?
-
Getting an error when trying to handle calendar popup
I was trying to handle a calendar popup and then getting an error.
It's unable to click on the date.Code that I have used is:
driver.findElement(By.xpath("//*[@id='bidExpirationDate']")).click(); List<WebElement> alldates=driver.findElements(By.xpath("//td[@role='gridcell']")); System.out.println("All date: "+alldates.size()); for(WebElement d:alldates) { String date=d.getText(); if(date.equalsIgnoreCase("21")) { d.click(); break; } }
Output: All date: 42
Exception in thread "main" org.openqa.selenium.WebDriverException: [JavaScript Error: "b.elementFromPoint is not a function" {file: "file:///C:/Users/Office/AppData/Local/Temp/anonymous2113754378902429082webdriver-profile/extensions/fxdriver@googlecode.com/components/synthetic-mouse.js" line: 11130}]' [JavaScript Error: "b.elementFromPoint is not a function" {file: "file:///C:/Users/Office/AppData/Local/Temp/anonymous2113754378902429082webdriver-profile/extensions/fxdriver@googlecode.com/components/synthetic-mouse.js" line: 11130}]' when calling method: [wdIMouse::click] Command duration or timeout: 58 milliseconds
How i can resolve this error?
-
Firefox extension open page using POST
In Firefox extension I need to open a specific webpage in new tab and I need to send POST data to it. I have full control over target webpage (my server).
What I've tried so far is..
This is actually sending GET with no data (but works in Chrome. Possibly a CSP limitation..) Chrome Extension Development - POST to new tab
Instead of using generated FORM on the webpage, i tried XmlHttpRequest. I can successfully send the post request and get the answer, but I only get the response as plain text and can't open it in current window (I only get static content without working scripts upon inserting it to the page's BODY)
I played with the XHR response a bit and tried:
document.open(); document.write(xhr.responseText);
but I get "Loading of source self ("script-src") was blocked due to CSP".
So I tried to find the answer how to set CSP and headers and I inserted a header:
<meta http-equiv="Content-Security-Policy" content="script-src 'self'">
on both local and the remote page. It did not help, though.
Does anyone know a solution please?
-
Selenium with Python Error Message: "Failed to find firefox binary."
I am using Python 3.6.5 32 bits (with Selenium 3.11.00 installed via pip install selenium), Firefox 59.0.2 (64-bit) and geckodriver-v0.20.1-win64, and my OS is Windows 7 Professional 64 bits.
While running the code below I got the error below. Could please someone help me?
Code:
from selenium import webdriver from selenium.webdriver.common.desired_capabilities import DesiredCapabilities cap = DesiredCapabilities().FIREFOX cap["marionette"] = False browser = webdriver.Firefox(capabilities=cap, executable_path="C:/Users/Trajano/AppData/Local/Programs/Python/Python36-32/Scripts") browser.get('http://google.com/') browser.quit()
Error message:
Traceback (most recent call last): File "C:\Users\Trajano\AppData\Local\Programs\Python\Python36-32\seleniumtests.py", line 6, in <module> browser = webdriver.Firefox(capabilities=cap, executable_path="C:/Users/Trajano/AppData/Local/Programs/Python/Python36-32/Scripts") File "C:\Users\Trajano\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 167, in __init__ self.binary = FirefoxBinary() File "C:\Users\Trajano\AppData\Local\Programs\Python\Python36-32\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 50, in __init__ "Failed to find firefox binary. You can set it by specifying " selenium.common.exceptions.WebDriverException: Message: Failed to find firefox binary. You can set it by specifying the path to 'firefox_binary': from selenium.webdriver.firefox.firefox_binary import FirefoxBinary binary = FirefoxBinary('/path/to/binary') driver = webdriver.Firefox(firefox_binary=binary)
-
WebDriverException: 'geckodriver' executable needs to be in PATH even though it is
Trying to get firefox to run using selenium in spyder. My current code is
from selenium import webdriver import os os.environ["PATH"] += ":/usr/local/bin/geckodriver" browser = webdriver.Firefox()
and I still get this error:
runfile('/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder/test.py', wdir='/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder') Traceback (most recent call last): File "<ipython-input-1-3f3f96ccf515>", line 1, in <module> runfile('/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder/test.py', wdir='/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder') File "/Applications/anaconda3/lib/python3.6/site- packages/spyder/utils/site/sitecustomize.py", line 705, in runfile execfile(filename, namespace) File "/Applications/anaconda3/lib/python3.6/site- packages/spyder/utils/site/sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace) File "/Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder/test.py", line 12, in <module> browser = webdriver.Firefox() File "/Applications/anaconda3/lib/python3.6/site- packages/selenium/webdriver/firefox/webdriver.py", line 152, in __init__ self.service.start() File "/Applications/anaconda3/lib/python3.6/site- packages/selenium/webdriver/common/service.py", line 83, in start os.path.basename(self.path), self.start_error_message) WebDriverException: 'geckodriver' executable needs to be in PATH.
Even though gekodriver is in that folder.
I have also tried exporting the path to ~./bash_profile which looks like this right now.
Last login: Fri Apr 20 10:57:16 on ttys000 dhcp-54-85:~ mherl$ nano ./bash_profile dhcp-54-85:~ mherl$ nano .bash_profile GNU nano 2.0.6 File: .bash_profile Modified # Setting PATH for Python 3.6 # The original version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}" export PATH # Setting PATH for Python 3.6 # The original version is saved in .bash_profile.pysave PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}" export PATH # added by Anaconda3 5.1.0 installer export PATH="/Applications/anaconda3/bin:$PATH" #added by mherl to show path to gekodriver export PATH=$PATH:/usr/local/bin/gekodriver
I also have the current paths set in spyder:
/usr/local/bin /Users/mherl/Dropbox/AnacondaProjects/MWS/MWSSpyder
of which gekodriver is in
/usr/local/bin
I have looked everywhere and most people say it should run automatically if it's in /usr/local/bin but it still can't seem to find it even when I explicitly state the path.
This is a mac running High Sierra if that's important.
-
How to access Django's development server using Tor Browser?
I already installed and created a Django project. Then I run the command
python manage.py runserver
, which gives me:Performing system checks... System check identified no issues (0 silenced). You have 14 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions. Run 'python manage.py migrate' to apply them. April 19, 2018 - 16:28:03 Django version 2.0.4, using settings 'personal.settings' Starting development server at http://127.0.0.1:8000/ Quit the server with CONTROL-C.
All is well, and if I access
http://127.0.0.1:8000/
on Mozilla Firefox, I get the initial 'Congratulations!' page with the rocket taking off. If I accesshttp://127.0.0.1:8000/
on Tor Browser, however, I get an 'Unable to connect' error. I can access other websites normally.What's the problem here, and how can I access my development server using Tor Browser instead of Mozilla Firefox?
-
frequent packets recieved while opening tor
I am trying to view the traffic from my computer to the first relay and backwords when uding tor. I use wireshark to view the packets sent. when I only open tor, this is what wireshark shows me: https://imgur.com/a/Reh0o (stack overdflow does not allow me to post images because I am new)
now, thats is what I see before even loading a website. I know that the 192.168 IP is mine and the second one is of the first server in the circuit. my question is- does anybody know what it sent from the server to me so frequently? I couldn't figure out what are these packets
thanks
-
Is there a way to correlate or find out the host of a virtual machine?
I'm learning about security and wondering, if I'm using a VM on any host (Windows or GNU/Linux) is it possible for someone (either in the same network or not) to gather information about my host (ip, mac address, location, etc.)
Is it possible using only a certain hypervisor (hyper-v, virtualvox,vmware,etc) or certain host?
I read that using Tails in a Virtual Machine is not that secure, because the host can compromise a guest and vice versa. How come?