0

First of all sorry for my english.

I have a page with radio-buttons. Here is the html code of the button I want to click.

<label class="radio-button__radio radio-button__radio_side_right radio-button__radio_next-for-pressed_yes" for="uniq13988671">
    <input id="uniq13988671" class="radio-button__control" type="radio" value="1000">
    <span class="radio-button__text">все</span>
</label>

my python script with selennium:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains as ac

driver = webdriver.Firefox()
driver.get("url_with_elements")
driver.implicitly_wait(20)

my_button = driver.find_element_by_css_selector("input[value='1000']")
ac(driver).move_to_element(my_button).perform()
my_button.click()

This button should reload the page with all elements (at least 1000) but it doesn't work. Ther's no any errors and element respond on method .get_attribute('id')

>>> my_button.get_attribute('id')
u'uniq13988671'

here is full html code of row with radio-buttons:

<td class="b-layout-table__cell">
    <div class="b-banners-per-page i-bem b-banners-per-page_js_inited" onclick="return {"b-banners-per-page":{"urlObject":{"hash":"","query":{"cmd":"setPageSize","subcmd":"showCamp","cid":"8868621","ulogin":"*mylogin*"},"file":"main.NWluTm99mAw1N.pl","directory":"/registered/","path":"/registered/main.NWluTm99mAw1N.pl","relative":"/registered/main.NWluTm99mAw1N.pl","port":"","host":"direct.yandex.ru","password":"","user":"","userInfo":"","authority":"direct.yandex.ru","protocol":"https","source":"https://direct.yandex.ru/registered/main.NWluTm99mAw1N.pl"},"optimalBannersOnPage":20}}">
        <span class="b-banners-per-page__title">Объявлений на странице: </span>
        <div class="b-banners-per-page__buttons">
            <span class="radio-button radio-button_size_s radio-button_theme_normal i-bem radio-button_js_inited" onclick="return {"radio-button":{}}">
                <label class="radio-button__radio radio-button__radio_side_left" for="uniq13988675">
                <label class="radio-button__radio radio-button__radio_checked_yes radio-button__radio_pressed_yes" for="uniq13988674">
                <label class="radio-button__radio radio-button__radio_next-for-pressed_yes" for="uniq13988673">
                <label class="radio-button__radio" for="uniq13988672">
                <label class="radio-button__radio radio-button__radio_side_right" for="uniq13988671">
                    <input id="uniq13988671" class="radio-button__control" type="radio" value="1000">
                    <span class="radio-button__text">все</span>
                </label>
            </span>
        </div>
    </div>
</td>

Here's the image of how it looks like "step by step" https://i.sstatic.net/QB5Gi.png

I'm looking at other questions but they don't help me. Thanks for any help.

ADD: If i use Selenium IDE addon for firefox. this button clicked fine.

If need more info - please ask.

2
  • 2
    Are you getting an error? If so, can you edit your post and add the error? I'm guessing the code is not finding the element, and that can be caused by a couple of different issues. If the element you are trying to click is in a frame or iframe, or if the element is slow to load. Commented Apr 30, 2014 at 15:01
  • Add more info. The element was found successfully. Commented Apr 30, 2014 at 18:06

1 Answer 1

2

I've handle my problem use construction like that:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver import ActionChains as ac

driver = webdriver.Firefox()
driver.get("url_with_elements")
driver.implicitly_wait(20)

# my_button = driver.find_element_by_css_selector("input[value='1000']")
button_parent = driver.find_element_by_xpath("//td[2]/div/div/span/label[5]")
ac(driver).move_to_element(button_parent).perform()
button_parent.click()
ac(driver).send_keys(Keys.SPACE).perform()
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.