I have been trying to scroll through the small pop up window from selenium since a while now. I am trying to create an auto follow bot. But I am unable to either follow or scroll through this. I am trying this code but I don't think I am using a correct Xpath.
How can I get the correct Xpath so that I can scroll through the window?
Also when I try to follow without scrolling it throws an error too. So what can be the possible solution for this?
followers_popup= self.driver.find_element(By.XPATH,'//*.
[#id="mount_0_0_vA"]/div/div/div/div[2]/div/div/div[1]
/div/div[2]/div/div/div/div/div[2]/div/div')
for i in range(5):
self.driver.execute_script("arguments[0].scrollTop=
arguments[0].scrollHeight",followers_popup)
time.sleep(5)
Related
I have been working on some RobotFramework stuff and I am having an issue. I am trying to access ta set of links that appear when the settings menu is pressed. I assume that we would need to do some window switching but am having trouble with it as I am pretty new to RF and Python. Would anyone be able to point in the direction of some assistance? I have tried using the documentation but I just cant seem to get it.
Thank you
p.s this is some code where I seem to be getting the issue
Go to http://localhost/index.php?redirect=0
Click Element id:quickaccess-popover-content
Click Element //*[#id="quickaccess-popover content"]/div[2]/div[2]/ul/li[1]/a
Does anyone know of a way to check if the scrollbar in Chrome has reached the bottom without using a detectable module like Selenium? Basically I just want the script to check a page that has already been opened in Chrome in a natural undetectable way to see if the scroll has reached bottom and if it hasn't then execute some code.
I have a project to get some information from website.
I want to look at the process inside the chrome window, So I can't use headless browser. But sometimes I want to minimize the chrome window.
But I found the selenium would go wrong after I minimize the chrome window manually, but sometimes not. When go wrong, exception
element is not clickable at the point, other element will receive the click
will be raised, or sometimes selenium just stop.
I have searched for a long time that some people said that the chrome window should be focused on and can't be minimized by clicking '-' on the window title bar. And the alternative solution is:
web.set_window_position(-2000,-2000)
To make the window move out the screen.
And someone says by simulating shortcuts to minimize the window. But I think it's the same as click '-' manually, am I wrong?
My question is :
Does selenium really requires chrome window not minimized? Why sometimes it can run selenium normally after minimized but sometimes not?
If I use
set_window_position(-2000,-2000)
to move the window invisible, then I click the window icon on the bottom of os (I'm sorry that I don't know what it's called). Normally when clicked, the window will be minimized. So as for this chrome window, Will it be considered as minimized window and go wrong?
I am really sorry for my poor English. I hope I have a clear description of my problem.
Environment:
python 3.6
chrome 66.0
selenium 3.11.0
windows server 2012
Edit to add code:
wait.WebDriverWait(driver,100000).until(EC.visibility_of_element_located((By.ID,'commMgrCompositionMessage')))
textArea = driver.find_element_by_id('commMgrCompositionMessage')
driver.execute_script("arguments[0].value="+"'"+modelStr+"';",textArea)
time.sleep(1)
wait.WebDriverWait(driver,10000).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR,'#sendemail_label')))
allSendMailLabel = driver.find_elements_by_css_selector('#sendemail')
allSendMailLabel = allSendMailLabel[1]
driver.execute_script("arguments[0].click();", allSendMailLabel)
If you see the question here Debugging "Element is not clickable at point" error, there is a bug in the chromedriver that causes this. The issue for it was created here. There is a workaround listed in the 27th comment, but what you can do is switch to the firefox driver and see if that works. Minimised windows should not cause a problem otherwise.
I'm working on a bit of automation that basically opens YouTube, plays a particular video, then opens the "Stats for Nerds" dialog and grabs the info from it. This was working yesterday. Today, I added lines to set the video to 1080p, then go into full screen, and now it fails to work.
The following line works:
driver.find_element_by_id("movie_player").click()
While this set fails, throwing a StaleElementReferenceException:
element = driver.find_element_by_id("movie_player")
actions.move_to_element(element)
actions.context_click(element)
actions.perform()
Nothing I have done can avoid this. I've tried putting it in a try block, with and without some waits thrown in. Somehow the element is going stale in the very short time between finding and setting the element, and performing the context_click action.
Is there any way of getting around this?
Edit: I'll keep checking back in to see if someone knows a better way to do this, but for now, in the interest of expediency, I've just kludged it by using pymouse to actually take control of the mouse and right click.
I suspect the DOM changes if you mouse over the button. To workaround it, "refind" the element:
element = driver.find_element_by_id("movie_player")
actions.move_to_element(element).perform()
element = driver.find_element_by_id("movie_player")
actions.context_click(element).perform()
So I have a website which has a combo that I need to select an item from, now the problem is it's a bit untraditional and doesn't have option's as elements but instead it has divs.
So I need my program to click combo box then wait (the best way to do this I found is via implicitly_wait(3)# 3 seconds) and then click the box element I need. Firefox is doing a great job with it but PhantomJS seem to throw:
Selenium.common.exceptions.ElementNotVisibleException:
Message: 'Error Message => \'Element is not currently visible and may not be manipulated\'
I'm not sure what's the cause of it, but I suspect that PhantomJS fails to correctly wait via implicitly_wait for some reason and tries to select non-visible element.
Any idea how to approach this without forced thread sleep?
Yup, your issue sounds exactly something I've just fixed in a UI test that was starting to anoy me. Quite a complex one, that passed on all browsers, except my favorite PhantomJs (which is the fastest).
It was quite anoying, when in the debugger I could clearly see that even the parent element was set to visible. Only the prime faces component I needed to click for whatever reason (not CSS or active Styles) was not visible.
After looking at Phantom JS screenshot, I realized the window was quite tiny, and indeed the UI element was not visually visible.
You see now where I am geting at?
Phantom JS is a headless browser, it does not render you the window, but it does use a window, and the window does have a size.
The exception is quite unexpected, because the engine behind is the same as the one used for chrome and safari ... things should just work.
Well, and they did in the end.
Try to tune your driver factory like this:
WebDriver driver = new PhantomJSDriver();
driver.manage().window().setSize(new Dimension(800, 600));
return driver;
Good luck.