Selenium won't return HTTP error codes on its own, but it does allow you to attach a proxy before a browser is started. With a tool like BrowserMobProxy, you can record network traffic and assert certain conditions requests are present or contain HTTP traffic codes.
I haven't tried it personally, but some browsers will let you access the logs as outlined here:
https://stackoverflow.com/questions/25431380/capturing-browser-logs-with-selenium
Check out this stack overflow
It appears you can do it through the youtube api.
Generally speaking, anything you have to do through web driving, is likely going to be a violation of the terms of service.
You could still pursue a selenium solution, and now that I understand you mean 'click a button labeled monetize' and not 'make money off of' when you say monetize, you can probably do it through selenium but the api will be much more reliable.
You'll probably want the VMs to auto-login, using something like http://www.computerperformance.co.uk/windows7/windows7_auto_logon.htm. If you ever log onto the box with rdp, you'll want to reboot when you leave it. It doesn't take much for the display adapter to lose its mind.
If you find everything works but things randomly go black you may also want something like http://www.zhornsoftware.co.uk/caffeine/ to keep the display alive.
I think you're going about it all wrong. I went to their site, and unless you show me a different UI. It's just a link then it brings up file explorer to upload a file to their site.
This means you would have to inject javascript with the path to the file you want to upload directly into the input type = file. It is because the current field is hidden
I don't believe you can directly sendkeys and type into that input field even when you unhide it.
This is a related article to your problem: https://stackoverflow.com/questions/17739529/need-help-for-webdriver-and-javascript-for-a-hidden-file-upload-element
based on that question, looks like there are ways to make that field visible and inject a file name into the input field and then force the site to upload the file.
Hope this helps.
Ditch Selenium and look at Google's Puppeteer library they released last week. It drives the new headless feature of Chrome with a much simpler API deliberately meant for automation without a primary focus on automated testing.
Their example in their README is actually about ten lines long and shows how to make screenshots.
Doing a quick google search for stack overflow (sorry I woke up about 15 minutes ago and first thing is Reddit...), I found this answer that sounds like it could help you:
https://stackoverflow.com/questions/33695690/webdriver-set-initial-url
Even though it's "setting" the homepage to "about:blank", it could still do the job you're looking for.
You could publish this as a dependency you pull in: Maven Publishing - You would likely want a private repository where you publish to keep that from being public.
You could also investigate git submodules.
Hey
This is interesting stuff.
I pulled up the IDE, just for an initial inspection. http://recordit.co/jWGFEdlFWL
One thing that shouted out, was that the onBlur event was not firing. So that meant selenium was yet to see the change occur.
I see you are triggering selenium.focus("id=content2"); which would presumably get around this.
I was doing some PHP Webdriver stuff the other day and I noticed a similar issue with AJAX calls. One element, that was straight up there, was not being found by id=XXX.
One thing that helped was targeting via xpath. ( perhaps it triggers more of the DOM )
How does xpath=(//div[@class='MarkdownEditor']/div[@class='content']) fair?
What you're looking to do likely isn't possible. To my knowledge, Selenium cannot interact with the browser UI itself. It can only automate actions within web pages.
EDIT: Another tool called Appium may be able to help, check here: http://appium.io/docs/en/writing-running-appium/web/mobile-web/ Appium is very similar to Selenium, but it automates mobile devices, so you'll need either a real device, or an emulator.
EDIT 2: Apparently Chromedriver may support running Chrome in mobile emulation mode, but as far as I can tell it doesn't allow switching between mobile and desktop on the fly. http://chromedriver.chromium.org/mobile-emulation
Honestly, I wouldn’t say that using the Chrome extension (aka Selenium IDE) is automation - it’s a macro playback tool at best and is inherently very limited in what it can do, and it’s inherently inelegant.
Nevertheless, why would you need to click a bookmark if you can just designate the URL you’d like Selenium IDE to navigate to every time? Are you testing your site or the Chrome browser(which is silly)?
Either way, here’s a link to show you how to “Open” a URL - it was the first link that popped up in the Google search.
They had a live demo on their site. It's using HTML canvas, which Selenium isn't really suited to dealing with. However, if you really want to go there, it might be possible, as outlined in this stack article:
https://stackoverflow.com/questions/18254564/interacting-with-a-canvas-with-selenium
OOOOOH!
Got it.
Your problem is you are in an iFrame.
Take a look at this stack overflow solution.
(I don't think you need to switch out of a frame first, as in that answer, you just need to switch in most likely)
iFrame's embed in your dom and you can't find the content within by normal methods. But you can find the frame and then switch into the frame, then do normal finds within the frame.
Might want to add some of your code, I don't think Anyone can answer your question otherwise.
You need to find ou if there is a bottleneck, and where it is. What is taking so long? to find the part that's slow you can try profiling your script.
If the problem isn't in a bottleneck, you will probably not be ablo to make your script faster with asynchronous programming - keep in mind that asynchronous isn't multithreading - in python.
It didnt seem to be. Grabbed a quick print screen for you if this is any help at all?
https://snipboard.io/yPDstI.jpg
I am very rusty here so I could well be staring it right in the face without knowing
Let me make sure I understand what you're trying to do.
You use Python/Selenium/Chromedriver to save the file "weather.png" which is a screenshot of the url in browser.get
You then open the file with python, see how the screenshot compares to the width of 240, save it as a ratio
Multiply the vertical size by that same ratio, save it into hsize to get pixel height as adjusted by the ratio
Rescale the image according to the ratio, apply antialiasing to new image and save as kia.png
Then after this script runs comes the problem - once the browser closes your weather display application doesn't come back to fullscreen?
I question why use Selenium at all in this use case. The real goal is to get a screenshot of a website, correct? You can do that with chrome directly in a headless way where it won't launch a full window and thus wouldn't minimize your weather display application. You can even tell the browser the size you want before you take the screenshot.
I'm not very good at Python but this works for me and launches chrome all in the background and thus might solve the problem for you (obviously will need some changes since you are running a different OS):
import os from datetime import datetime import time
screenshotName = "weather" url = "https://www.windy.com/?54.355,-6.943,6,i:pressure" getdate = datetime.now().strftime("%m-%d-%y")
screenshotDestination="C:\Test"
chromedir="\"\"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe\"\""
screenshotPath=f'{screenshotDestination}\{screenshotName }{getdate}.png'
chromeParams=f'--screenshot={screenshotPath} --headless --hide-scrollbars --window-size=1920,1080 {url}'
fullCommand=f'{chromedir} {chromeParams}'
try: stream = os.system(fullCommand) time.sleep(10) except: print("Screenshot failed.")
You aren't returning anything from the functions, and you generally need to keep the object returned from webdriver.Chrome() throughout your script.
The things I do wrap in functions are parsing logic, I pass DOM elements to those and either print in those functions or write to a DB or return something. (WebElements returned from the driver.find_element_by_* functions)
You could return the webdriver.Chrome() object from your first function, and pass it to your second login page.
Judging by the way you phrased your question, I'm guessing you don't understand what PATH is.
Your logic is right that it has to do with directories but not quite in the way that you're thinking.
When you see PATH capitalized (or sometimes like $PATH as one of the other commenters put it), it is referring to the PATH environment variable. Your PATH variable usually contains a list of several directories on your machine. It is in these directories that your computer looks for commands when you try to execute them.
Brief example: A small subset of my $env:PATH looks like:
C:\WINDOWS;C:\Windows\System32,C:\Python39\,C:\Python39\Scripts\
This means when I type "python simplescript.py" on command line, windows will look for a python executable in the directories listed above. Once it finds the python executable, it will try to find simplescript.py in the $PATH directories.
Looping that back into your problem, there are a few possibilities.
When I need to find an executable on my windows machine and I'm not sure where it might be, I use the tool Everything: https://www.voidtools.com/
It's a free tool and I cannot live without it these days.
I'm betting you're on windows. If you're able to find where the chromedriver lives, run this command in cmd or powershell:
set PATH=%PATH%;C:\your\path\to\chromedriver\
(bear in mind this is the path to the FOLDER not the path including chromedriver.exe)
You are right, i have gone ahead and altered the code and also used Firefox's webdriver because it seems it can open the url better. Also i can get the screenshot now:
​
def get_profit():
profit = equity = ''
opts = FirefoxOptions()
opts.add_argument( "--headless" )
with webdriver.Firefox( firefox_options=opts, executable_path='/usr/bin/geckodriver' ) as driver:
wait = WebDriverWait(driver, 10)
driver.get( 'https://www.etoro.com/login' )
wait.until( EC.element_to_be_clickable(( By.ID, "username" ))).send_keys("*****")
wait.until( EC.element_to_be_clickable(( By.ID, "password" ))).send_keys("******")
wait.until( EC.element_to_be_clickable(( By.XPATH, "/html/body/ui-layout/div/div/div[1]/et-login/et-login-sts/div/div/div/form/button" ))).click()
driver.save_screenshot( 'static/img/etoro.png' )
profit = wait.until( EC.element_to_be_clickable(( By.XPATH, "/html/body/ui-layout/div/div/footer/et-account-balance/div/div[5]/span[1]" ))).text
profit = wait.until( EC.element_to_be_clickable(( By.XPATH, "/html/body/ui-layout/div/div/footer/et-account-balance/div/div[7]/span[1]" ))).text
driver.quit()
return profit, equity
The problem now is that the after clikcing the logn page to enter the main site with the values, that page seems to not get loaded because i get Timeouts. The screenshot gets corretly taken because it displays what the image looks like after the screenshot.
BUT whay the next page enver gets opened so the code to retruve the profit and equity values?
Hi there u/Liberal__af - I'm sorry that the options on our website are overwhelming. We do have quite a lot of options, and for a first-time customer, I bet that it could be a bit tricky to know which product is best for your specific usecase. If you go to a product page on our website, for example, this one https://www.hetzner.com/managed-server, you'll see a red chat icon in the bottom right corner during our normal business hours here in Germany. You can go to this chat to talk to our sales technicians. They can give you some guidance one what product could work for your requirements. --Katie, Marketing, Hetzner Online
Well you said "connection... keeps dropping," which I took as "going down" rather than "slowing down." As in dropping connection.
I'd have expected Ookla to have a (public) API interface, but it doesn't appear they do. I did find this python library though.
Incidentally, once upon a time, there was a project called "Flash-Selenium" that would allow automation of Flash applications, though I think it might have required a custom-compiled swf. (I used a similar project called Selenium Flex which required that.)
The most widely used application is Wireshark. It can do everything you need to sniff both your phone's wireless traffic as well as your browser traffic. It's not too difficult to use, but I would spend some time learning how to utilize the filters so it only grabs traffic going to Instagram's APIs.
Not really, CSS selectors can do lot more than just matching classes.
https://saucelabs.com/resources/articles/selenium-tips-css-selectors
as /u/Chet_Steadman sain in very good and detailed response probably the UI framework bugs the XPathif you can tell what is the what is the component probably we can help with the XPath From what i saw in https://material.angular.io/components/checkbox/overview after click on the check box the there was some changes in the html i used this XPath and manage to click it a few times in a row //label[contains(.,'Primary')]/child::div[@class[contains(.,'mat-checkbox')]] probably it can be done better
https://www.techbeamers.com/websites-to-practice-selenium-webdriver-online/
I tend to keep data-driven testing to unit tests or API tests. I would use Selenium for an end to end test, but not every possible scenario. They’re too slow and flaky to be the only testing you do.
Try send_keys(Keys.CONTROL,Keys.SHIFT,'M')
I suspect the reason that ctrl+t doesn't appear to work is because Selenium does not automatically switch its focus to a new tab; you have to use switch_to_window() to explicitly switch focus to the new tab.
Hello fren.
I can recommend this one https://www.techbeamers.com/selenium-webdriver-tutorial/
They have really good explanation and a lot of examples how to write tests (Java and Python too).
Selenium has a language binding for dart, but it is not officially developed by seleniumhq.org,
PFB the link to dart client for Selenium WebDriver https://github.com/google/webdriver.dart (Check selenium downloads page for all language bindings)
However I assume the output of flutter will not be a Web App but a build for mobiles in APK/IPA Format which Appium will be able to recognise. And it does not have a language binding with dart yet. http://appium.io/docs/en/about-appium/appium-clients/
Do let us know about it if it works for you.
i'm sure its similar in java or python, whatever language you are using. i'm just more familiar with c#.
Here’s a link that might help. https://www.browserstack.com/guide/test-chrome-extensions-in-selenium
Hey there! So, disclaimer: I work at Atlassian. We make a continuous delivery server called Bamboo, which has tons of nifty integrations with JIRA and works well with Selenium (also Junit, TestNG, PHPunit, etc.) http://www.atlassian.com/software/bamboo
Happy testing! -S.
I run jenkins on a rasberryPI at home. It will watch slashdot.org, and hold a list of the last 3 posts on the page.
Every time it gets an update, it will email me a link, with the snipits of the article. Also, it takes the linked texts/links from the snipit and post them into the email.
I made this because subscribing to slashdot's email list will always email me the next day, of the day before (or the day before that's) articles.... and i've already read them, and commented.
This way, every half hour i get updated with whatever the new article is IFF there is a new one.
(github link en route, just cleaning it up, since i always hastily change things and comment out the old. it still has older versions of parsing slashdot, just in case they are #bringingitback)
Ctrl Shift C was the closest I got - it does what RClick Q does - takes me into 'Inspector' for the mouseover element
but I can't expand the div or do anything besides scroll up/down using arrow keys
https://developer.mozilla.org/en-US/docs/Tools/Keyboard_shortcuts#page_inspector Page Inspector has just one hotkey! C-S-c
Just to tag on, here's where a few users like to go to get started. https://www.elastic.co/start
​
Disclaimer: : I'm with Elastic (the company behind the Elastic Stack - aka ELK Stack).
​
Enjoy!
​
​
https://ui.vision/rpa/docs/selenium-ide/executescript
> The executeScript command executes a snippet of JavaScript in the context of the currently selected frame or window. The script fragment will be executed as the body of an anonymous function. To store the return value, use the 'return' keyword and provide a variable name in the value input field.
Here's the full error
test_selenium.py
from selenium import webdriver from selenium.webdriver.common.keys import Keys
driver = webdriver.Firefox() driver.get("http://www.python.org") assert "Python" in driver.title elem = driver.find_element_by_name("q") elem.send_keys("pycon") elem.send_keys(Keys.RETURN) assert "No results found." not in driver.page_source driver.close()
...and the error:
Traceback (most recent call last):
File "/home/pi/python/test_selenium.py", line 4, in <module> driver = webdriver.Firefox() File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/webdriver.py", line 77, in init self.binary, timeout), File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/extension_connection.py", line 49, in init self.binary.launch_browser(self.profile) File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 68, in launch_browser self._wait_until_connectable() File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/firefox/firefox_binary.py", line 103, in _wait_until_connectable raise WebDriverException("Can't load the profile. Profile " WebDriverException: Message: Can't load the profile. Profile Dir: %s If you specified a log_file in the FirefoxBinary constructor, check it for details.
Iceweasel is v31 and selenium is 2.46.
What I have done here is using selenium as a data scrapper. I was trying to scrap data from the local website that I have created as a test. When I run this selenium tester with Windows Application it takes about 42 seconds. However, when I move this to my ASP.NET CORE Web Application, it takes little bit more than 2 minutes. Here is the example of the code that I have used in Web application cause this is the code that I will eventually use. Both of them does not have a difference. If you have any idea why this code is running slowly that would help me A LOT. Thank you. here is the code link: "https://codeshare.io/G734w1"
We have "sites" on our intranet. The problem is that the browser.get doesn't even seem to run (even with a working URL). It opens the browser, but doesn't even try to process the URL. In my mind, that script should open the browser, then load http://seleniumhq.org/ (which would just give an error because there is no internet connectivity). The problem is it's not even trying to go to the URL. Do you follow?
it's linked from the downloads page: http://seleniumhq.org/download/ (API Docs)
So, here's a better link that will always be updated with every selenium release: http://selenium.googlecode.com/svn/trunk/docs/api/rb/index.html
There are quite a few books out there you can read. I used Selenium WebDriver Practical Guide and it was pretty good. You can look in the "Customers also Bought" section to find a few more examples.