I am trying to save the same stuff with selenium in my Yandex account, the problem is that when I try to pass the code to click the button "save to Yandex disk", selenium pass me the message unable to locate the element.
Thats my code:
browser.find_element_by_xpath('/html/body/div[1]/div/div[2]/div[1]/div[1]/div/div[1]/div[3]/button[1]').click()
this is the page with the button "Save to yandex disk": https://yadi.sk/d/0ReZErv_cLl1-w
I read that u can also pass elements by name or by CSS selector, but when I try with firefox inspector to copy element, the browser gives me strange code.
Any suggestions?
..of course, the same error with or without logged into Yandex.
Thank you
You can use this XPath for detecting needed element:
//div[#class = 'folder-content content content_other content_dir']//button[contains(#class, "save")]
Use this xpath //*[contains(text(),'Save to Yandex.Disk')] to click "Save to Yandex.Disk" button
First thing is that we need to improve the xpath you are using to find the element we should use the xpath that is relative but in your case you are using the xpath that is absolute, I use the extension chropath in chrome to find the xpath of the element
Below mentioned is the chro path I would recommend you to use although the above two mentioned xpath can also be used
Let me know If you have any more queries, I can form a good xpath for you
//div[#class='folder-content__header']//span[contains(text(),'Save to Yandex.Disk')]
Below mentioned is one of the xpath I have used in my own project take a look maybe this can improve your horizon
//label[contains(text(),'Plant Code*')]//parent::div[#class='rb_Work_FieldContainer']//following-sibling::div[contains(#class,'rb_Work_FieldValueArea rb_Work_FieldValueArea_create ')]//textarea[#class='textarea']
Related
I want to make a automatic google login with selenium but i cannot find the elements, the buttoenter image description heren "Next", because the class
is modified each time when we come to start a browser with selenium, or when we reset the login page and does not have Id, but the button is in a div that includes just this button,
I would like someone to help me find a solution to find how I can use this button in order to click it to skip the page where you have to put your email address to skip to the password
i would like to use css selector
(Google Chrome the browser I use)
I code with Selenium 4.2.0 on Linux Unbuntu
driver.find_element(By.CSS_SELECTOR, 'button[class="VfPpkd-LgbsSe VfPpkd-LgbsSe-OWXEXe-k8QpJ VfPpkd-LgbsSe-OWXEXe-dgl2Hf nCP5yc AjY5Oe DuMIQc LQeN7 qIypjc TrZEUc lw1w4b"]').click()
That will click the 'Next' button on Google login. Good luck getting any further though. Google seems to block logging in on Chromium.
You can either use jsname as an alternative for finding the element
I found a similar question here How can I inspect element in to div with jsname?
I think the person is doing pretty same thing
Hope this helps :)
I am trying to get the value from webpage using selenium base on python. However, I do not get the point about how to make it. The value I want to catch is in the red mark side of below picture. Please help me to figure out this. Thank you very much!
Please click here to check the picture
There are few ways (By css,by xpath...) I recommend you reading this page: http://selenium-python.readthedocs.io/locating-elements.html
You also need some understanding about html, css and the DOM but the simplest way to get the value you want is by xpath (But its the slowest)
Open your web browser lets say chrome, right click on the element you want and inspect. It will open developer tools and you will have the html line selected already, right click it again-> copy -> copy xpath
from selenium import webdriver
driver = webdriver.Chrome('/path/to/chromedriver')
driver.get("http://www.web.com")
driver.find_element_by_xpath(the_xpath_you_copied_before_from_dev_tools).text
I am interacting with svg elements in a web page.
I am able to locate the svg elements by xpath, but not able to click it, The error mentions that the methods like click(), onclick() are not available.
Any suggestions of how can we make it clickable ? please advice ?
Try to make use of Actions or Robot class
I am using Selenium WebDriver to do automated testing of a website. I have been successful in clicking through numerous menus and links to a point.
At one point the website I am working with generates links that look like this:
<U onclick="HourglassSubmitItem(document.all('PageName').value, '00000001Responsibility Code')">Responsibility Code</U>
I am trying to use the .click functionality of the webdriver to click this link with no success.
Using this:
page.find_element_by_xpath("//u[contains(text(),'Responsibility Code')]")
successfully finds the U tag above. but when I add .click() to the end of this xpath, the click is not performed. But it also does not generate an error. So, my question is can Selenium be used to simulate clicks on an HTML tag that is NOT an anchor () tag? If so, how?
I will also say that I do not have control over the page I am working with, so changing the to is not possible.
I would appreciate any guidance the Community could provide.
Thank You for you help,
Chris
Sometimes using JavaScript could solve the "clicking" issue:
element = page.find_element_by_xpath("//u[contains(text(),'Responsibility Code')]")
page.execute_script('arguments[0].click();', element)
You can prefer JavaScript in this case.
WebElment element = page.find_element_by_xpath("//u[contains(text(),'Responsibility Code')]")
JavaScriptExecutor executor = (JavaScriptExecutor)driver;
executor.ExecuteScript("arguments[0].click();", element);
I am trying to click a button to show more comments on a discusson thread on http://disqus.com/
The HTML looks like following:
<div class="load-more" data-role="more" style="">
Show more
</div>
I have tried using the xPath from the button like following:
driver = webdriver.Chrome("/usr/lib/chromium-browser/chromedriver")
driver.get(url)
driver.find_element_by_xpath('''//*[#id="posts"]/div[3]/a''').click()
But I get the NoSuchElement exception.
What is the proper way of clicking a button with that type of HTML?
UPDATE: Worked when I switched to a specific iFrame:
driver.switch_to.frame('myID')
Then loaded by class name:
element = driver.find_element_by_class_name('load-more')
element.click()
NOTE: That the click() did not work when it was performed on the same line like driver.find_element_by_class_name('load-more').click()
Xpath should be a last resort for finding elements. For your case, I would try
driver.find_element_by_class_name("load-more__button"));
Using btn load-more__button won't work as compound classNames aren't valid.
If that still doesn't work, Id recommend using css selectors before Xpath.
However, if none of these options work, and your Xpath is still not working, you should use the firebug add on for Firefox to ensure the Xpath you are using is correct.
Here's some of my other answers that may help you get started with Firebug:
https://stackoverflow.com/a/38980488/3537915
https://stackoverflow.com/a/38723782/3537915
https://stackoverflow.com/a/38744577/3537915