How use python selenium webdriver on flex container - python

I am automating some task with selenium webdriver for python.
I am curently on a selection by classname that is behaving strangely (only 4 of the 10 elements are found), I believe that is because the elements I am looking for are in a flexbox. Could that be it?
If so, I saw to handle flexbox one should use a add on on selenium, I saw this one https://code.google.com/archive/p/sfapi/downloads, buts it's for Java. What would you advice for python?
Thanks

Related

Does it matter if used new tab or new window if I am going to use headless browser in python helium

I am using helium library for web scraping dynamic websites
I found it much faster to use tabs than using many windows yet some websites when I open them in a new tab they show some ads and I could not find a way to close them. That made me look for a lot of JS codes, which I do not understand, and most of the times they are not working when executed using helium library in python even though they work fine in the Console of Google Chrome.
However, the code should be running headless and I am doing all of this only for testing and here is my main question
Does it matter if used new tab or new window if I am going to use headless browser in python helium
is it going to be faster just like what happens when it runs normal or since it is headless it makes no difference ?
not to forget to mention that it is way easier for me to work with many windows since I won't have to use JS codes.
driver.execute_script('''$x('xpath')[0].remove();''')
driver.execute_script('''$x('xpath')[0].click();''')
$x('xpath')[0].remove();
$x('xpath')[0].click();
selenium.common.exceptions.JavascriptException: Message: javascript error: $x is not defined
they both work just fine in Google Chrome Console but for some reason, I can not execute them python helium.
I tried using to give more time using time.sleep(5) to load the page but it did not work
not to mention that I tried using the click() method from helium it gives me a LookupError()
I found a way to test it for myself it might not be accurate but the results gave me a clear winner I used the windows task manager to see the percentage of CPU usage in all the cases when running headless tabs were faster and used way less CPU than new windows

How does one use selenium and python to interact with a rateit widget?

This question might actually have been asked before, but I have scoured the net looking for the answer, but to no avail.
So my team has an automation project using selenium in python. The issue now is that on the website there is a "rateit" widget implemented, where one has to highlight a set out of five stars to give a rating.
This is the rateit widget: https://github.com/gjunge/rateit.js/wiki
I have tried everything from using the ActionChain.move_to_element to click element by off set.

Is there a way of being able to solve a captcha in Python MANUALLY

I have started getting into python web automation(with chrome). I am using python 3 and selenium module. Is there a way of having the recaptcha pop up in a seperate window allowing me to solve it like normal and then carrying on with my set automation?
Any advice is much apprectaited
Thanks
Image of captcha

Recording video of headless selenium browser

I've been working with selenium in Python recently.
I was curious if anyone has had experience with recording an instance of a headless browser? I tried finding a way to do this, but didn't find any solutions in Python - a code example would be excellent.
Some tips would be helpful.
I don't think they have any built in way to do this with any of the browsers. Your best bet would be to connected to the same instance of the browser (this is easier if you use the grid server) from another program then just take screenshots at short intervals.

Selenium ActionChains working on some PCs, not others

I'm developing a data scraping script using Selenium and Python and I've got the following line of code which works on my Ubuntu PC, my wife's Windows PC but not my colleague's Windows PC.
ActionChains(driver).context_click(inputElement).send_keys(Keys.ARROW_DOWN).click().perform()
We're in the UK and he is in Canada is the only difference I know of.
EDIT
What I've realised is happening, but I do not know how to resolve, is the Keys.ARROW_DOWN is being performed on the webpage and not on the context_click element. Any thoughts? Is this a Chrome issue?
That might be a timing issue related to the quality of the network connection to the target site.
I'd strengthen it by introducing an Explicit Wait for the inputElement, use the WebDriverWait with element_to_be_clickable Expected Condition before starting the action chain.
You may also add a "scroll into view" of the element to tackle potential browser/resolution/etc specific layout issues:
driver.execute_script("arguments[0].scrollIntoView();", inputElement)
Solution:
I rewrote using Firefox instead of Chrome and it is working fine.

Categories