mardi 20 août 2019

Ruby : How to add a specific line from a document.txt to a comment field with specific id and then move to next line?

How can i add a specific line from my document.txt to youtube comment field with specific id and then move to next line on my document.txt . The id of youtube comment field is 'contenteditable-root' . I have created this code but the text that is been added on the youtube comment field show in brackets for example ["Hello"]

Or in second example it shows nothing

Example 1:

file = 'comments.txt'
File.readlines(file).each do |i|
            files = [i]
            files.each { |val| 

browser.execute_script("document.getElementById('contenteditable-root').innerHTML = '#{files}';")

}
end

Example 2:

line_number = 1 
loop do
comments = IO.readlines('comments.txt')[line_number-1]
browser.execute_script("document.getElementById('contenteditable-root').innerHTML = '#{comments}';")
line_number += 1 
end

Aucun commentaire:

Enregistrer un commentaire