Home > Mobile >  Is there another way to click on a menu item with Capybara
Is there another way to click on a menu item with Capybara

Time:06-02

Friends try anyway but it is not being possible to click on the Gestão de Materiais Menu item. One situation I need is to scroll this menu to view and click on the item menu. But I'm not sure why he is clicking on the menu item below I tried using SitePrism and pure capybara but it is not possible. When it runs, it is clicking on Gestao de Empresas

capybara: find(:xpath, "//div[contains(text(),'Gestão de Materiais')]" ).click find(:xpath, '//*[@id="TBB_tbm2"]/div[3]/div[2]').click

site Prism: element :item_mn_gestao_materiais, :xpath, "//div[contains(text(),'Gestão de Materiais')]" element :item_mn_gestao_materais, :css, '#TBB_tbm2 img[src*=articoli64]' def cadastra_diametro_material_ativo item_mn_gestao_materiais.click end enter image description here Menu Principal Modulo Básico Gestão Instalações Gestão de Materiais <div

enter image description here

CodePudding user response:

There is no point in trying Capybara and SitePrism, SitePrism uses capybara so if capybaras click doesn't work for you then SitePrism isn't going to either.

It's very hard to tell what is going on here because your screen shots have popups over the structure of the page, also screen shots make it much harder to answer since we can't copy paste from them (use screenshots for pictures of your page, not HTML. Add HTML as text in the question). You also aren't showing how you're detecting that it's clicking the wrong button. What exactly is failing? Please see https://stackoverflow.com/help/how-to-ask

Given the visible info, if I was writing this I'd write

find('#TBB_tbm2 > div', text: 'Gestão de Materiais').click

following the two rules

  1. Don't use XPath unless absolutely necessary
  2. Write the minimal selector necessary

beyond that it's impossible to go any further with the current information

  • Related